Skip to content

Commit 6eb9269

Browse files
committed
Updating description.md
1 parent 0e138d7 commit 6eb9269

File tree

1 file changed

+74
-18
lines changed

1 file changed

+74
-18
lines changed
Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,85 @@
11
# Description
22

3-
A complex number is a number in the form `a + b * i` where `a` and `b` are real and `i` satisfies `i^2 = -1`.
3+
A **complex number** is expressed in the form:
44

5-
`a` is called the real part and `b` is called the imaginary part of `z`.
6-
The conjugate of the number `a + b * i` is the number `a - b * i`.
7-
The absolute value of a complex number `z = a + b * i` is a real number `|z| = sqrt(a^2 + b^2)`. The square of the absolute value `|z|^2` is the result of multiplication of `z` by its complex conjugate.
5+
```
6+
z = a + b * i
7+
```
88

9-
The sum/difference of two complex numbers involves adding/subtracting their real and imaginary parts separately:
10-
`(a + i * b) + (c + i * d) = (a + c) + (b + d) * i`,
11-
`(a + i * b) - (c + i * d) = (a - c) + (b - d) * i`.
9+
where:
1210

13-
Multiplication result is by definition
14-
`(a + i * b) * (c + i * d) = (a * c - b * d) + (b * c + a * d) * i`.
11+
- `a` is the **real part** (a real number),
1512

16-
The reciprocal of a non-zero complex number is
17-
`1 / (a + i * b) = a/(a^2 + b^2) - b/(a^2 + b^2) * i`.
13+
- `b` is the **imaginary part** (also a real number), and
1814

19-
Dividing a complex number `a + i * b` by another `c + i * d` gives:
20-
`(a + i * b) / (c + i * d) = (a * c + b * d)/(c^2 + d^2) + (b * c - a * d)/(c^2 + d^2) * i`.
15+
- `i` is the imaginary unit satisfying `i^2 = -1`.
2116

22-
Raising e to a complex exponent can be expressed as `e^(a + i * b) = e^a * e^(i * b)`, the last term of which is given by Euler's formula `e^(i * b) = cos(b) + i * sin(b)`.
17+
### Key Properties
2318

24-
Implement the following operations:
19+
1. **Conjugate**: The conjugate of the complex number `z = a + b * i` is given by:
2520

26-
- addition, subtraction, multiplication and division of two complex numbers,
27-
- conjugate, absolute value, exponent of a given complex number.
21+
```
22+
z̅ = a - b * i
23+
```
2824

29-
Assume the programming language you are using does not have an implementation of complex numbers.
25+
2. **Absolute Value**: The absolute value (or modulus) of `z` is defined as:
26+
27+
```
28+
|z| = sqrt(a^2 + b^2)
29+
```
30+
31+
The square of the absolute value, `|z|²`, can be computed as the product of `z` and its conjugate:
32+
33+
```
34+
|z|² = z * z̅ = a² + b²
35+
```
36+
37+
### Operations on Complex Numbers
38+
39+
1. **Addition**: The sum of two complex numbers `z₁ = a + b * i` and `z₂ = c + d * i` is computed by adding their real and imaginary parts separately:
40+
41+
```
42+
z₁ + z₂ = (a + c) + (b + d) * i
43+
```
44+
45+
2. **Subtraction**: The difference of two complex numbers is obtained by subtracting their respective parts:
46+
47+
```
48+
z₁ - z₂ = (a - c) + (b - d) * i
49+
```
50+
51+
3. **Multiplication**: The product of two complex numbers is defined as:
52+
53+
```
54+
z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i
55+
```
56+
57+
4. **Division**: The division of one complex number by another is given by:
58+
59+
```
60+
z₁ / z₂ = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i
61+
```
62+
63+
5. **Reciprocal**: The reciprocal of a non-zero complex number is given by:
64+
65+
```
66+
1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i
67+
```
68+
69+
6. **Exponentiation**: Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula:
70+
71+
```
72+
e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b))
73+
```
74+
75+
### Implementation Requirements
76+
77+
Given that you should not use built-in support for complex numbers, implement the following operations:
78+
79+
- **Addition** of two complex numbers.
80+
- **Subtraction** of two complex numbers.
81+
- **Multiplication** of two complex numbers.
82+
- **Division** of two complex numbers.
83+
- Calculation of the **conjugate** of a complex number.
84+
- Calculation of the **absolute value** of a complex number.
85+
- Calculation of the **exponent** of a given complex number.

0 commit comments

Comments
 (0)