Hướng dẫn c++ print complex - c ++ in phức tạp
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 (). Show
Nội dung chính
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ápcomplex([real[, imag]]) Tạo một số phức tạp đơn giản trong Python>>> c = 3 +6j >>> print(type(c)) 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ạpMô -đun Python CMATH >>> #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) Giai đoạn của số phức >>> c2 <= c2 Traceback (most recent call last): File " Mô -đun Python CMATHGiai đoạn của số phức Giai đoạn của số phứcKết quả Hằng số mô -đun CMATH 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 CMATHKết quả import cmath print('π =', cmath.pi) print('e =', cmath.e) print('tau =', cmath.tau) print('Positive infinity =', cmath.inf) print('Positive Complex infinity =', cmath.infj) print('NaN =', cmath.nan) print('NaN Complex =', cmath.nanj) Kết quảπ = 3.141592653589793 e = 2.718281828459045 tau = 6.283185307179586 Positive infinity = inf Positive Complex infinity = infj NaN = nan NaN Complex = nanj Hằng số mô -đun CMATHKết quả import cmath c = 1 + 2j print('e^c =', cmath.exp(c)) print('log2(c) =', cmath.log(c, 2)) print('log10(c) =', cmath.log10(c)) print('sqrt(c) =', cmath.sqrt(c)) Kết quả>>> c = 3 +6j >>> print(type(c))0 Hằng số mô -đun CMATH>>> c = 3 +6j >>> print(type(c))1 Kết quả>>> c = 3 +6j >>> print(type(c))2 Hằng số mô -đun CMATH>>> c = 3 +6j >>> print(type(c))3 Kết quả>>> c = 3 +6j >>> print(type(c))4 Hằng số mô -đun CMATH
Làm thế nào để bạn in một loại phức tạp trong Python?Điều gì là phức tạp () trong Python? returns a complex number ( real + imaginary) example (5+2j) when real and imaginary parts are passed, or it also converts a string to a complex number. Điều gì là phức tạp () trong Python?Làm thế nào để bạn viết tưởng tượng tôi trong Python?returns a complex number by specifying a real number and an imaginary number. Làm thế nào để bạn viết tưởng tượng tôi trong Python?Python có cú pháp phức tạp không?the symbol j is used to denote the imaginary unit. Python có cú pháp phức tạp không?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.complex(real, imaginary). The complex in python, takes two parameters, the first parameter is required , but the second is optional. The complex in python generates a complex number using the parameters passed and returns the generated complex number. |