Tổng của một số thực và một số ảo gọi là số phức. Đây là những số có thể được viết dưới dạng a + ib. trong đó a và b đều là số thực. Nó được ký hiệu là z
Giá trị của i là [√-1] hoặc có thể viết là i2 = -1
Ví dụ
- 3+4i là một số phức, trong đó 3 là số thực [Re] và 4i là số ảo [Im]
- 2+5i là một số phức trong đó 2 là số thực [Re] và 5i là số ảo [I'm]
Hợp của số thực và số ảo gọi là số phức
số ảo
Số không có thực gọi là số ảo. Sau khi bình phương một số ảo, nó cho kết quả âm. Số ảo được biểu diễn dưới dạng Im[].
Thí dụ. √-3, √-7, √-11 đều là số ảo. ở đây 'i' là một số ảo được gọi là "iota"
Điều gì xảy ra khi bạn bình phương một số ảo?
Số không có thực gọi là số ảo. Sau khi bình phương một số ảo, nó cho kết quả âm. Số ảo được biểu diễn dưới dạng Im[]. Số có thể viết dưới dạng số thực nhân với đơn vị ảo i được gọi là số ảo
Thí dụ. √3i, √-4i, √-11 đều là số ảo. ở đây 'i' là một số ảo được gọi là "iota". Giá trị của i là [√-1] hoặc có thể viết là i2 = -1
Cho hai số nguyên dương A và B biểu diễn số phức Z dưới dạng Z = A + i * B, nhiệm vụ là tìm căn bậc hai của số phức đã cho
ví dụ
Đầu vào. A = 0, B =1
Đầu ra.
Căn bậc hai là.
0. 707107+0. 707107*i
-0. 707107 – 0. 707107*iĐầu vào. A = 4, B = 0
Đầu ra.
Căn bậc hai là.
2
-2
Cách tiếp cận. Vấn đề đã cho có thể được giải quyết dựa trên các quan sát sau
- Biết rằng căn bậc hai của một số phức cũng là một số phức
- Sau đó xem xét căn bậc hai của số phức bằng X + i*Y, giá trị của [A + i*B] có thể được biểu thị bằng
- A + i * B = [X + i * Y] * [X + i * Y]
- A + i * B = X2 – Y2+ 2 * i * X * Y
- Cân bằng giá trị của từng phần thực và phức
Từ các quan sát trên, hãy tính giá trị của X và Y bằng công thức trên và in giá trị [X + i*Y] dưới dạng giá trị căn bậc hai kết quả của số phức đã cho
Dưới đây là việc thực hiện các phương pháp trên
C++
// C++ program for the above approach
#include
using
namespace
std;
// Function to find the square root of
// a complex number
void
complexRoot[
// C++ program for the above approach
0 // C++ program for the above approach
1_______00 // C++ program for the above approach
3
// C++ program for the above approach
4
// C++ program for the above approach
5// C++ program for the above approach
6
// C++ program for the above approach
5// C++ program for the above approach
8// C++ program for the above approach
9#include
0// C++ program for the above approach
9#include
2
// C++ program for the above approach
5#include
4
// C++ program for the above approach
5// C++ program for the above approach
9 #include
7_______18#include
9using
0using
1using
0using
3
using
4using
5
using
6using
7
// C++ program for the above approach
5// C++ program for the above approach
9 namespace
0
// C++ program for the above approach
5namespace
2
// C++ program for the above approach
5namespace
4
// C++ program for the above approach
5namespace
6
// C++ program for the above approach
5// C++ program for the above approach
9 namespace
9
// C++ program for the above approach
5// C++ program for the above approach
9 std;
2
// C++ program for the above approach
5std;
4
// C++ program for the above approach
5std;
6 std;
7
std;
8std;
9
std;
8// Function to find the square root of
1
std;
8// Function to find the square root of
3
// C++ program for the above approach
5// Function to find the square root of
5
// C++ program for the above approach
5// Function to find the square root of
7
// C++ program for the above approach
5// C++ program for the above approach
9 // a complex number
0using
0// a complex number
2
// C++ program for the above approach
5// a complex number
4
// C++ program for the above approach
5std;
6 // a complex number
7
std;
8// a complex number
9#include
8#include
9using
0void
3
std;
8// C++ program for the above approach
9 void
6
std;
8std;
9
std;
8// Function to find the square root of
1
std;
8complexRoot[
2
std;
8complexRoot[
4
std;
8// C++ program for the above approach
9 complexRoot[
7
std;
8// C++ program for the above approach
9 // C++ program for the above approach
00
std;
8std;
6 // C++ program for the above approach
03
// C++ program for the above approach
04// C++ program for the above approach
05
// C++ program for the above approach
04// C++ program for the above approach
07
// C++ program for the above approach
04// C++ program for the above approach
09
std;
8// Function to find the square root of
5
// C++ program for the above approach
5// Function to find the square root of
5
// C++ program for the above approach
5// C++ program for the above approach
15
// C++ program for the above approach
5// C++ program for the above approach
17____018
// C++ program for the above approach
19// C++ program for the above approach
20
// C++ program for the above approach
5// C++ program for the above approach
22 #include
9____024 // C++ program for the above approach
25
std;
8// C++ program for the above approach
27
std;
8std;
6 // C++ program for the above approach
30
// C++ program for the above approach
04// C++ program for the above approach
17// C++ program for the above approach
33// C++ program for the above approach
34
std;
8std;
6 // C++ program for the above approach
37
// C++ program for the above approach
04// C++ program for the above approach
39
// C++ program for the above approach
40// C++ program for the above approach
41// C++ program for the above approach
42 // C++ program for the above approach
20
std;
8// C++ program for the above approach
45
// C++ program for the above approach
04// C++ program for the above approach
47
// C++ program for the above approach
5// Function to find the square root of
5
// Function to find the square root of
5
// C++ program for the above approach
51
// C++ program for the above approach
0 // C++ program for the above approach
53
// C++ program for the above approach
4
// C++ program for the above approach
5// C++ program for the above approach
0 // C++ program for the above approach
57
// C++ program for the above approach
5// C++ program for the above approach
59
// C++ program for the above approach
5// C++ program for the above approach
61 // C++ program for the above approach
62
// Function to find the square root of
5
Java
// C++ program for the above approach
64
// C++ program for the above approach
65 // C++ program for the above approach
66
// C++ program for the above approach
67 // C++ program for the above approach
68
// C++ program for the above approach
5
// C++ program for the above approach
70 // C++ program for the above approach
67 // C++ program for the above approach
72
// C++ program for the above approach
4
// C++ program for the above approach
5// C++ program for the above approach
9 // C++ program for the above approach
76
// C++ program for the above approach
5// C++ program for the above approach
78 // C++ program for the above approach
79______09 // C++ program for the above approach
81
// C++ program for the above approach
82// C++ program for the above approach
9 // C++ program for the above approach
84
// C++ program for the above approach
5// C++ program for the above approach
4
std;
8// C++ program for the above approach
88// C++ program for the above approach
89
_______48____088// C++ program for the above approach
92
// C++ program for the above approach
5// C++ program for the above approach
94
// Function to find the square root of
5
// Function to find the square root of
// a complex number
// C++ program for the above approach
70 void
complexRoot[
// C++ program for the above approach
0 // C++ program for the above approach
1// C++ program for the above approach
0 // C++ program for the above approach
3
// C++ program for the above approach
4
// C++ program for the above approach
5
// C++ program for the above approach
5// C++ program for the above approach
6
// C++ program for the above approach
5#include
10____111 #include
12
// C++ program for the above approach
5#include
4
// C++ program for the above approach
5// C++ program for the above approach
9 #include
17
#include
18#include
19____120#include
21
// C++ program for the above approach
5// C++ program for the above approach
9 #include
24#include
20 #include
26
// C++ program for the above approach
5namespace
2
// C++ program for the above approach
5#include
30____111 #include
32
// C++ program for the above approach
5namespace
6
// C++ program for the above approach
5// C++ program for the above approach
9 #include
37____138 #include
39
// C++ program for the above approach
5// C++ program for the above approach
9 #include
42#include
20 #include
44
// C++ program for the above approach
5std;
4
// C++ program for the above approach
5std;
6 #include
49#include
50#include
51
// C++ program for the above approach
5// C++ program for the above approach
4
std;
8
std;
8std;
9
std;
8// Function to find the square root of
1
std;
8#include
30#include
11 #include
62
// C++ program for the above approach
5// Function to find the square root of
5
// C++ program for the above approach
5// Function to find the square root of
7
// C++ program for the above approach
5// C++ program for the above approach
9 #include
69____120// C++ program for the above approach
34
// C++ program for the above approach
5// a complex number
4
// C++ program for the above approach
5std;
6 #include
76____150#include
51
// C++ program for the above approach
5// C++ program for the above approach
4
std;
8#include
82
std;
8// C++ program for the above approach
9 #include
85______120 #include
87
std;
8std;
9
std;
8// Function to find the square root of
1
std;
8#include
30#include
11 #include
95
std;
8complexRoot[
4
std;
8// C++ program for the above approach
9 using
00#include
38 using
02
std;
8// C++ program for the above approach
9 using
05____120 using
07
std;
8std;
6 using
10#include
50#include
51
std;
8// C++ program for the above approach
4
// C++ program for the above approach
04
// C++ program for the above approach
04// C++ program for the above approach
05
// C++ program for the above approach
04// C++ program for the above approach
07
// C++ program for the above approach
04#include
30#include
11 using
23
std;
8// Function to find the square root of
5
// C++ program for the above approach
5// Function to find the square root of
5
// C++ program for the above approach
5// C++ program for the above approach
15
// C++ program for the above approach
5using
31____018 using
33using
34using
35
// C++ program for the above approach
5// C++ program for the above approach
22using
38
// C++ program for the above approach
5// C++ program for the above approach
4
std;
8using
42using
43using
44
std;
8std;
6 using
47____150#include
51
_______004using
31____033using
35
std;
8std;
6 using
56____150#include
51
// C++ program for the above approach
04using
42____261using
62
std;
8// C++ program for the above approach
45
// C++ program for the above approach
04using
66
// C++ program for the above approach
5// Function to find the square root of
5
// Function to find the square root of
5
// C++ program for the above approach
51
// C++ program for the above approach
78 // C++ program for the above approach
70 void
using
74
// C++ program for the above approach
4
// C++ program for the above approach
5// C++ program for the above approach
0 using
78#include
50using
80#include
38// C++ program for the above approach
34
// C++ program for the above approach
5
// C++ program for the above approach
5// C++ program for the above approach
59
// Function to find the square root of
5
// Function to find the square root of
5
using
88
Python3
using
89
using
90 using
91// C++ program for the above approach
65 using
0
using
94
using
95
using
96 using
97
// C++ program for the above approach
5
// C++ program for the above approach
5namespace
00
// C++ program for the above approach
5namespace
02____303 namespace
04
// C++ program for the above approach
5namespace
06
// C++ program for the above approach
5namespace
08namespace
03 #include
8namespace
11using
33 namespace
13namespace
14 namespace
15using
33 namespace
17namespace
14 namespace
19namespace
20 #include
20namespace
22
// C++ program for the above approach
5namespace
24namespace
03 namespace
17namespace
20 #include
9#include
20 namespace
14 namespace
31
// C++ program for the above approach
5namespace
33
// C++ program for the above approach
5namespace
35
// C++ program for the above approach
5namespace
37
// C++ program for the above approach
5namespace
39namespace
03 namespace
41#include
38 namespace
14 namespace
08
// C++ program for the above approach
5namespace
46namespace
03 namespace
17namespace
20 #include
9#include
20 namespace
14 namespace
53
// C++ program for the above approach
5namespace
55
// C++ program for the above approach
5std;
6 namespace
58namespace
03 #include
50namespace
61
std;
8namespace
63
std;
8namespace
65
std;
8namespace
67
// C++ program for the above approach
5namespace
69
// C++ program for the above approach
5namespace
71namespace
03 namespace
73namespace
41 namespace
13namespace
14 namespace
15using
33 namespace
17namespace
14 namespace
19namespace
20 #include
20
// C++ program for the above approach
5namespace
85
// C++ program for the above approach
5std;
6 #include
76____150namespace
61
std;
8namespace
71____303 #include
8namespace
95
std;
8namespace
97namespace
03 namespace
17namespace
20 #include
9#include
20 namespace
14 std;
04
std;
8namespace
63
std;
8namespace
65
std;
8std;
10
_______48____412
std;
8std;
14namespace
03 namespace
41#include
38 namespace
14 namespace
71
std;
8std;
21______303 namespace
17namespace
20 #include
9#include
20 namespace
14 std;
28
std;
8std;
6 std;
31namespace
03 #include
50namespace
61
_______004____436
_______004____438
// C++ program for the above approach
04std;
40
// C++ program for the above approach
5std;
42
// C++ program for the above approach
5std;
44#include
9// C++ program for the above approach
18#include
51
// C++ program for the above approach
5// C++ program for the above approach
22 std;
50std;
51 std;
52
std;
8std;
44#include
9std;
56std;
57#include
50____459std;
60std;
61namespace
03 std;
63
std;
8std;
6 std;
57____138std;
68#include
50namespace
61
// C++ program for the above approach
04std;
44#include
9std;
86#include
9std;
56std;
57#include
38std;
59std;
60namespace
22using
33 // C++ program for the above approach
42#include
51