Hướng dẫn how do you plot a real part of a complex number in python? - làm thế nào để bạn vẽ một phần thực của một số phức 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().

import cmath

x = 5

The phase of complex number is : 3.141592653589793
0=
The phase of complex number is : 3.141592653589793
2

The phase of complex number is : 3.141592653589793
3=
The phase of complex number is : 3.141592653589793
5
The phase of complex number is : 3.141592653589793
6

The phase of complex number is : 3.141592653589793
7
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)
2

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

The phase of complex number is : 3.141592653589793
7
The phase of complex number is : 3.141592653589793
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
7
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)
2

The phase of complex number is : 3.141592653589793
7
f(k) = Re[k - 0.5*(sqrt(1 - 4*k) + 1)]
2

Đầ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.

import cmath

x = 5

The phase of complex number is : 3.141592653589793
0=
The phase of complex number is : 3.141592653589793
2

The phase of complex number is : 3.141592653589793
3=
The phase of complex number is : 3.141592653589793
5
The phase of complex number is : 3.141592653589793
6

The phase of complex number is : 3.141592653589793
7
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)
2

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

Output:

The phase of complex number is : 3.141592653589793

The phase of complex number is : 3.141592653589793
7
The phase of complex number is : 3.141592653589793
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
7
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)
2

The phase of complex number is : 3.141592653589793
7
f(k) = Re[k - 0.5*(sqrt(1 - 4*k) + 1)]
2 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)

import cmath

x = 5

The phase of complex number is : 3.141592653589793
0=
The phase of complex number is : 3.141592653589793
2

The phase of complex number is : 3.141592653589793
3=
The phase of complex number is : 3.141592653589793
5
The phase of complex number is : 3.141592653589793
6

The phase of complex number is : 3.141592653589793
3=
The phase of complex number is : 3.141592653589793
5
The phase of complex number is : 3.141592653589793
6

The phase of complex number is : 3.141592653589793
7
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)
2

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

The phase of complex number is : 3.141592653589793
7
The phase of complex number is : 3.141592653589793
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
7
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)
2

The phase of complex number is : 3.141592653589793
7
f(k) = Re[k - 0.5*(sqrt(1 - 4*k) + 1)]
2

Đầu ra:

The phase of complex number is : 3.141592653589793
7
The phase of complex number is : 3.141592653589793
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
7
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)
2

Output:

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

The phase of complex number is : 3.141592653589793
7
f(k) = Re[k - 0.5*(sqrt(1 - 4*k) + 1)]
2
 

Đầ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


Tôi đang cố gắng vẽ các chức năng sau đây ...

f(k) = Re[k - 0.5*(sqrt(1 - 4*k) + 1)]

Đối với 54, nhưng điều tốt nhất tôi có thể làm là ...

import matplotlib.pyplot as plt
import numpy as np
k = np.linspace(-2, 2, 100)
f = np.real(k - 0.5*(np.sqrt(1 - 4*k) + 1))
plt.plot(k, f)
plt.axis([-2,2,-10,10])

mà âm mưu tốt cho 55 nhưng không có gì cho kết quả phức tạp. Tôi có thể làm điều này theo cách khác không?

Làm thế nào để bạn vẽ những con số phức tạp trong Python?

Các bước để vẽ các số phức tạp trong Python 3:..
Nhập thư viện matplotlib ..
Lấy số lượng điểm được vẽ làm đầu vào từ người dùng ..
Tạo hai danh sách trống. ....
Tạo một vòng lặp để nối các phần thực và tưởng tượng của số trong danh sách ..
Sử dụng các phương thức thư viện để xác định màu sắc, nhãn, điểm đánh dấu, v.v.

Những con số phức tạp làm thế nào để Python đại diện cho một số phức với phần thực là gì?

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.Python complex number can be created either using direct assignment statement or by using complex () function. Complex numbers which are mostly used where we are using two real numbers.

Làm thế nào để bạn vẽ dữ liệu thời gian thực trong Python?

Để tạo ra một cốt truyện thời gian thực, chúng ta cần sử dụng mô-đun hoạt hình trong matplotlib.Chúng tôi thiết lập hình và trục theo cách thông thường, nhưng chúng tôi vẽ trực tiếp vào các trục, rìu, khi chúng tôi muốn tạo một khung mới trong hình ảnh động.use the animation module in matplotlib. We set up the figure and axes in the usual way, but we draw directly to the axes, ax , when we want to create a new frame in the animation.

Làm thế nào để bạn đại diện cho các phần 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.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 .