From 6eb9269d5acf2995bfabd4352255dffa062c8aae Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 12 Nov 2024 20:07:07 +0530 Subject: [PATCH 01/18] Updating description.md --- exercises/complex-numbers/description.md | 92 +++++++++++++++++++----- 1 file changed, 74 insertions(+), 18 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index c1aca4a582..cfaef68ec0 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -1,29 +1,85 @@ # Description -A complex number is a number in the form `a + b * i` where `a` and `b` are real and `i` satisfies `i^2 = -1`. +A **complex number** is expressed in the form: -`a` is called the real part and `b` is called the imaginary part of `z`. -The conjugate of the number `a + b * i` is the number `a - b * i`. -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. +``` +z = a + b * i +``` -The sum/difference of two complex numbers involves adding/subtracting their real and imaginary parts separately: -`(a + i * b) + (c + i * d) = (a + c) + (b + d) * i`, -`(a + i * b) - (c + i * d) = (a - c) + (b - d) * i`. +where: -Multiplication result is by definition -`(a + i * b) * (c + i * d) = (a * c - b * d) + (b * c + a * d) * i`. +- `a` is the **real part** (a real number), -The reciprocal of a non-zero complex number is -`1 / (a + i * b) = a/(a^2 + b^2) - b/(a^2 + b^2) * i`. +- `b` is the **imaginary part** (also a real number), and -Dividing a complex number `a + i * b` by another `c + i * d` gives: -`(a + i * b) / (c + i * d) = (a * c + b * d)/(c^2 + d^2) + (b * c - a * d)/(c^2 + d^2) * i`. +- `i` is the imaginary unit satisfying `i^2 = -1`. -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)`. +### Key Properties -Implement the following operations: +1. **Conjugate**: The conjugate of the complex number `z = a + b * i` is given by: -- addition, subtraction, multiplication and division of two complex numbers, -- conjugate, absolute value, exponent of a given complex number. +``` +z̅ = a - b * i +``` -Assume the programming language you are using does not have an implementation of complex numbers. +2. **Absolute Value**: The absolute value (or modulus) of `z` is defined as: + +``` +|z| = sqrt(a^2 + b^2) +``` + +The square of the absolute value, `|z|²`, can be computed as the product of `z` and its conjugate: + +``` +|z|² = z * z̅ = a² + b² +``` + +### Operations on Complex Numbers + +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: + +``` +z₁ + z₂ = (a + c) + (b + d) * i +``` + +2. **Subtraction**: The difference of two complex numbers is obtained by subtracting their respective parts: + +``` +z₁ - z₂ = (a - c) + (b - d) * i +``` + +3. **Multiplication**: The product of two complex numbers is defined as: + +``` +z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i +``` + +4. **Division**: The division of one complex number by another is given by: + +``` +z₁ / z₂ = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i +``` + +5. **Reciprocal**: The reciprocal of a non-zero complex number is given by: + +``` +1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i +``` + +6. **Exponentiation**: Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: + +``` +e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) +``` + +### Implementation Requirements + +Given that you should not use built-in support for complex numbers, implement the following operations: + +- **Addition** of two complex numbers. +- **Subtraction** of two complex numbers. +- **Multiplication** of two complex numbers. +- **Division** of two complex numbers. +- Calculation of the **conjugate** of a complex number. +- Calculation of the **absolute value** of a complex number. +- Calculation of the **exponent** of a given complex number. From f0e6fbdcd8d9c12821fed2c18d7f605cf1e51dc3 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 12 Nov 2024 22:25:35 +0530 Subject: [PATCH 02/18] Updating description.md --- exercises/complex-numbers/description.md | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index cfaef68ec0..7a965c90ae 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -2,7 +2,7 @@ A **complex number** is expressed in the form: -``` +```math z = a + b * i ``` @@ -14,65 +14,65 @@ where: - `i` is the imaginary unit satisfying `i^2 = -1`. -### Key Properties +## Key Properties 1. **Conjugate**: The conjugate of the complex number `z = a + b * i` is given by: -``` +```math z̅ = a - b * i ``` 2. **Absolute Value**: The absolute value (or modulus) of `z` is defined as: -``` +```math |z| = sqrt(a^2 + b^2) ``` The square of the absolute value, `|z|²`, can be computed as the product of `z` and its conjugate: -``` +```math |z|² = z * z̅ = a² + b² ``` -### Operations on Complex Numbers +## Operations on Complex Numbers 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: -``` +```math z₁ + z₂ = (a + c) + (b + d) * i ``` 2. **Subtraction**: The difference of two complex numbers is obtained by subtracting their respective parts: -``` +```math z₁ - z₂ = (a - c) + (b - d) * i ``` 3. **Multiplication**: The product of two complex numbers is defined as: -``` +```math z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` 4. **Division**: The division of one complex number by another is given by: -``` +```math z₁ / z₂ = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i ``` 5. **Reciprocal**: The reciprocal of a non-zero complex number is given by: -``` +```math 1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i ``` 6. **Exponentiation**: Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: -``` +```math e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) ``` -### Implementation Requirements +## Implementation Requirements Given that you should not use built-in support for complex numbers, implement the following operations: From 1d6473be7662d94e83f07215cb74f3285d81c053 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 12 Nov 2024 22:32:10 +0530 Subject: [PATCH 03/18] Updating description.md --- exercises/complex-numbers/description.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index 7a965c90ae..c34409c877 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -22,7 +22,7 @@ where: z̅ = a - b * i ``` -2. **Absolute Value**: The absolute value (or modulus) of `z` is defined as: +1. **Absolute Value**: The absolute value (or modulus) of `z` is defined as: ```math |z| = sqrt(a^2 + b^2) @@ -42,31 +42,31 @@ The square of the absolute value, `|z|²`, can be computed as the product of `z` z₁ + z₂ = (a + c) + (b + d) * i ``` -2. **Subtraction**: The difference of two complex numbers is obtained by subtracting their respective parts: +1. **Subtraction**: The difference of two complex numbers is obtained by subtracting their respective parts: ```math z₁ - z₂ = (a - c) + (b - d) * i ``` -3. **Multiplication**: The product of two complex numbers is defined as: +1. **Multiplication**: The product of two complex numbers is defined as: ```math z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` -4. **Division**: The division of one complex number by another is given by: +1. **Division**: The division of one complex number by another is given by: ```math z₁ / z₂ = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i ``` -5. **Reciprocal**: The reciprocal of a non-zero complex number is given by: +1. **Reciprocal**: The reciprocal of a non-zero complex number is given by: ```math 1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i ``` -6. **Exponentiation**: Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: +1. **Exponentiation**: Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: ```math e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) From d8a0cda58d355690ae9bde5622037e378214887c Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 12 Nov 2024 22:51:53 +0530 Subject: [PATCH 04/18] Updating description.md --- exercises/complex-numbers/description.md | 32 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index c34409c877..67700d016e 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -16,13 +16,17 @@ where: ## Key Properties -1. **Conjugate**: The conjugate of the complex number `z = a + b * i` is given by: +### Conjugate + +The conjugate of the complex number `z = a + b * i` is given by: ```math z̅ = a - b * i ``` -1. **Absolute Value**: The absolute value (or modulus) of `z` is defined as: +### Absolute Value + +The absolute value (or modulus) of `z` is defined as: ```math |z| = sqrt(a^2 + b^2) @@ -36,37 +40,49 @@ The square of the absolute value, `|z|²`, can be computed as the product of `z` ## Operations on Complex Numbers -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: +### 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: ```math z₁ + z₂ = (a + c) + (b + d) * i ``` -1. **Subtraction**: The difference of two complex numbers is obtained by subtracting their respective parts: +### Subtraction + +The difference of two complex numbers is obtained by subtracting their respective parts: ```math z₁ - z₂ = (a - c) + (b - d) * i ``` -1. **Multiplication**: The product of two complex numbers is defined as: +### Multiplication + +The product of two complex numbers is defined as: ```math z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` -1. **Division**: The division of one complex number by another is given by: +### Division + +The division of one complex number by another is given by: ```math z₁ / z₂ = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i ``` -1. **Reciprocal**: The reciprocal of a non-zero complex number is given by: +### Reciprocal + +The reciprocal of a non-zero complex number is given by: ```math 1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i ``` -1. **Exponentiation**: Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: +### Exponentiation + +Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: ```math e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) From 7ba41f37ff7f1ae3fb31a8386b5aa2864533d3b2 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 12 Nov 2024 22:54:37 +0530 Subject: [PATCH 05/18] Updating description.md --- exercises/complex-numbers/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index 67700d016e..de661e98c7 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -56,7 +56,7 @@ The difference of two complex numbers is obtained by subtracting their respectiv z₁ - z₂ = (a - c) + (b - d) * i ``` -### Multiplication +### Multiplication The product of two complex numbers is defined as: From 7d46dcc2266a7adf1653e81fac26e9111d549ebb Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 12 Nov 2024 23:04:04 +0530 Subject: [PATCH 06/18] Updating description.md --- exercises/complex-numbers/description.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index de661e98c7..4bb0a7a195 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -1,12 +1,6 @@ # Description -A **complex number** is expressed in the form: - -```math -z = a + b * i -``` - -where: +A **complex number** is expressed in the form `z = a + b * i`, where: - `a` is the **real part** (a real number), From 14e079de85fbbdc55c67150a7987199918db5a17 Mon Sep 17 00:00:00 2001 From: jagdish-15 Date: Wed, 13 Nov 2024 00:01:51 +0530 Subject: [PATCH 07/18] Update exercises/complex-numbers/description.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/complex-numbers/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index 4bb0a7a195..fab409f12a 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -6,7 +6,7 @@ A **complex number** is expressed in the form `z = a + b * i`, where: - `b` is the **imaginary part** (also a real number), and -- `i` is the imaginary unit satisfying `i^2 = -1`. +- `i` is the **imaginary unit** satisfying `i^2 = -1`. ## Key Properties From 738a0a15ef634d334a7d6de883150f2750b6c6ea Mon Sep 17 00:00:00 2001 From: jagdish-15 Date: Wed, 13 Nov 2024 00:26:05 +0530 Subject: [PATCH 08/18] Update exercises/complex-numbers/description.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/complex-numbers/description.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index fab409f12a..adcfe813fc 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -86,10 +86,10 @@ e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) Given that you should not use built-in support for complex numbers, implement the following operations: -- **Addition** of two complex numbers. -- **Subtraction** of two complex numbers. -- **Multiplication** of two complex numbers. -- **Division** of two complex numbers. -- Calculation of the **conjugate** of a complex number. -- Calculation of the **absolute value** of a complex number. -- Calculation of the **exponent** of a given complex number. +- **addition** of two complex numbers +- **subtraction** of two complex numbers +- **multiplication** of two complex numbers +- **division** of two complex numbers +- **conjugate** of a complex number +- **absolute value** of a complex number +- **exponent** of a complex number From ffb6d04a3c41e61d0e34ffe5d5db44aec31fd656 Mon Sep 17 00:00:00 2001 From: jagdish-15 Date: Wed, 13 Nov 2024 00:38:09 +0530 Subject: [PATCH 09/18] Update exercises/complex-numbers/description.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/complex-numbers/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index adcfe813fc..e2d847ab6e 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -92,4 +92,4 @@ Given that you should not use built-in support for complex numbers, implement th - **division** of two complex numbers - **conjugate** of a complex number - **absolute value** of a complex number -- **exponent** of a complex number +- **exponentiation** of the base _e_ (the natural logarithm) to a complex number From 5d6fc061d42ef41e66dab4dbbb6acbbb6865181d Mon Sep 17 00:00:00 2001 From: jagdish-15 Date: Wed, 13 Nov 2024 08:33:48 +0530 Subject: [PATCH 10/18] Update exercises/complex-numbers/description.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/complex-numbers/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index e2d847ab6e..51a8c52184 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -92,4 +92,4 @@ Given that you should not use built-in support for complex numbers, implement th - **division** of two complex numbers - **conjugate** of a complex number - **absolute value** of a complex number -- **exponentiation** of the base _e_ (the natural logarithm) to a complex number +- **exponentiation** of _e_ (the base of the natural logarithm) to a complex number From 80a5fad854b8d3419f1638ec46ffc330ca59ecb1 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Sun, 17 Nov 2024 16:43:35 +0530 Subject: [PATCH 11/18] Chnaging description of Complex-Number after suggestions --- exercises/complex-numbers/description.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index 51a8c52184..dfa7aeefa2 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -14,7 +14,7 @@ A **complex number** is expressed in the form `z = a + b * i`, where: The conjugate of the complex number `z = a + b * i` is given by: -```math +```plaintext z̅ = a - b * i ``` @@ -22,13 +22,13 @@ z̅ = a - b * i The absolute value (or modulus) of `z` is defined as: -```math +```plaintext |z| = sqrt(a^2 + b^2) ``` The square of the absolute value, `|z|²`, can be computed as the product of `z` and its conjugate: -```math +```plaintext |z|² = z * z̅ = a² + b² ``` @@ -38,7 +38,7 @@ The square of the absolute value, `|z|²`, can be computed as the product of `z` 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: -```math +```plaintext z₁ + z₂ = (a + c) + (b + d) * i ``` @@ -46,7 +46,7 @@ z₁ + z₂ = (a + c) + (b + d) * i The difference of two complex numbers is obtained by subtracting their respective parts: -```math +```plaintext z₁ - z₂ = (a - c) + (b - d) * i ``` @@ -54,7 +54,7 @@ z₁ - z₂ = (a - c) + (b - d) * i The product of two complex numbers is defined as: -```math +```plaintext z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` @@ -62,23 +62,15 @@ z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i The division of one complex number by another is given by: -```math +```plaintext z₁ / z₂ = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i ``` -### Reciprocal - -The reciprocal of a non-zero complex number is given by: - -```math -1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i -``` - ### Exponentiation Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: -```math +```plaintext e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) ``` From f0da7180c081b0f535699a85a7ac95d13d9a6d67 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Sun, 17 Nov 2024 17:45:52 +0530 Subject: [PATCH 12/18] Chnaging description of Complex-Number after suggestions --- exercises/complex-numbers/description.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index dfa7aeefa2..d8ce6c3729 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -26,6 +26,8 @@ The absolute value (or modulus) of `z` is defined as: |z| = sqrt(a^2 + b^2) ``` +### Sqaure + The square of the absolute value, `|z|²`, can be computed as the product of `z` and its conjugate: ```plaintext @@ -58,12 +60,20 @@ The product of two complex numbers is defined as: z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` +### Reciprocal + +The reciprocal of a non-zero complex number is given by: + +```math +1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i +``` + ### Division The division of one complex number by another is given by: ```plaintext -z₁ / z₂ = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i +z₁ / z₂ = z₁ * (1 / z₂) = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i ``` ### Exponentiation From 32d3e3d335bf06a8d0fbc2bd80e02715e7f6dd97 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Sun, 17 Nov 2024 17:47:21 +0530 Subject: [PATCH 13/18] Fixing consistancy issues --- exercises/complex-numbers/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index d8ce6c3729..18b0a93305 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -64,7 +64,7 @@ z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i The reciprocal of a non-zero complex number is given by: -```math +```plaintext 1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i ``` From e1e9bfffbd0aada2e84beaaf20d12cbf0c386013 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Sun, 17 Nov 2024 23:25:10 +0530 Subject: [PATCH 14/18] Changing description for complex-numbers --- exercises/complex-numbers/description.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index 18b0a93305..e957e5c726 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -14,7 +14,7 @@ A **complex number** is expressed in the form `z = a + b * i`, where: The conjugate of the complex number `z = a + b * i` is given by: -```plaintext +```text z̅ = a - b * i ``` @@ -22,15 +22,13 @@ z̅ = a - b * i The absolute value (or modulus) of `z` is defined as: -```plaintext +```text |z| = sqrt(a^2 + b^2) ``` -### Sqaure - The square of the absolute value, `|z|²`, can be computed as the product of `z` and its conjugate: -```plaintext +```text |z|² = z * z̅ = a² + b² ``` @@ -40,7 +38,7 @@ The square of the absolute value, `|z|²`, can be computed as the product of `z` 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: -```plaintext +```text z₁ + z₂ = (a + c) + (b + d) * i ``` @@ -48,7 +46,7 @@ z₁ + z₂ = (a + c) + (b + d) * i The difference of two complex numbers is obtained by subtracting their respective parts: -```plaintext +```text z₁ - z₂ = (a - c) + (b - d) * i ``` @@ -56,7 +54,7 @@ z₁ - z₂ = (a - c) + (b - d) * i The product of two complex numbers is defined as: -```plaintext +```text z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` @@ -64,7 +62,7 @@ z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i The reciprocal of a non-zero complex number is given by: -```plaintext +```text 1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i ``` @@ -72,7 +70,7 @@ The reciprocal of a non-zero complex number is given by: The division of one complex number by another is given by: -```plaintext +```text z₁ / z₂ = z₁ * (1 / z₂) = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i ``` @@ -80,7 +78,7 @@ z₁ / z₂ = z₁ * (1 / z₂) = (a + b * i) / (c + d * i) = (a * c + b * d) / Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: -```plaintext +```text e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) ``` From d0ca8606b56b77e17f68a4a2a2668816a5ecb2e2 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Mon, 18 Nov 2024 19:34:29 +0530 Subject: [PATCH 15/18] Updating sescription of complex-numbers exercise for consistancy --- exercises/complex-numbers/description.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index e957e5c726..b8e440803f 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -8,14 +8,14 @@ A **complex number** is expressed in the form `z = a + b * i`, where: - `i` is the **imaginary unit** satisfying `i^2 = -1`. -## Key Properties +## Operations on Complex Numbers ### Conjugate The conjugate of the complex number `z = a + b * i` is given by: ```text -z̅ = a - b * i +zc = a - b * i ``` ### Absolute Value @@ -26,20 +26,18 @@ The absolute value (or modulus) of `z` is defined as: |z| = sqrt(a^2 + b^2) ``` -The square of the absolute value, `|z|²`, can be computed as the product of `z` and its conjugate: +The square of the absolute value is computed as the product of `z` and its conjugate `zc`: ```text -|z|² = z * z̅ = a² + b² +|z|^2 = z * zc = a^2 + b^2 ``` -## Operations on Complex Numbers - ### 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: +The sum of two complex numbers `z1 = a + b * i` and `z2 = c + d * i` is computed by adding their real and imaginary parts separately: ```text -z₁ + z₂ = (a + c) + (b + d) * i +z1 + z2 = (a + c) + (b + d) * i ``` ### Subtraction @@ -47,7 +45,7 @@ z₁ + z₂ = (a + c) + (b + d) * i The difference of two complex numbers is obtained by subtracting their respective parts: ```text -z₁ - z₂ = (a - c) + (b - d) * i +z1 - z2 = (a - c) + (b - d) * i ``` ### Multiplication @@ -55,7 +53,7 @@ z₁ - z₂ = (a - c) + (b - d) * i The product of two complex numbers is defined as: ```text -z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i +z1 * z2 = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` ### Reciprocal @@ -63,7 +61,7 @@ z₁ * z₂ = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i The reciprocal of a non-zero complex number is given by: ```text -1 / z = 1 / (a + b * i) = a / (a² + b²) - b / (a² + b²) * i +1 / z = 1 / (a + b * i) = a / (a^2 + b^2) - b / (a^2 + b^2) * i ``` ### Division @@ -71,7 +69,7 @@ The reciprocal of a non-zero complex number is given by: The division of one complex number by another is given by: ```text -z₁ / z₂ = z₁ * (1 / z₂) = (a + b * i) / (c + d * i) = (a * c + b * d) / (c² + d²) + (b * c - a * d) / (c² + d²) * i +z1 / z2 = z1 * (1 / z2) = (a + b * i) / (c + d * i) = (a * c + b * d) / (c^2 + d^2) + (b * c - a * d) / (c^2 + d^2) * i ``` ### Exponentiation From 2c9e279a45c60828d087d4aae01c08ea6e4f51fa Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 19 Nov 2024 14:05:40 +0530 Subject: [PATCH 16/18] Updating description of complex-numbers --- exercises/complex-numbers/description.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index b8e440803f..2e54752d88 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -37,7 +37,7 @@ The square of the absolute value is computed as the product of `z` and its conju The sum of two complex numbers `z1 = a + b * i` and `z2 = c + d * i` is computed by adding their real and imaginary parts separately: ```text -z1 + z2 = (a + c) + (b + d) * i +z1 + z2 = (a + b * i) + (c + d * i) = (a + c) + (b + d) * i ``` ### Subtraction @@ -45,7 +45,7 @@ z1 + z2 = (a + c) + (b + d) * i The difference of two complex numbers is obtained by subtracting their respective parts: ```text -z1 - z2 = (a - c) + (b - d) * i +z1 - z2 = (a + b * i) - (c + d * i) = (a - c) + (b - d) * i ``` ### Multiplication From ddf83b922639b7a77b2e868dd17579bc1323e88b Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 19 Nov 2024 21:25:33 +0530 Subject: [PATCH 17/18] Updating description complex-numbers --- exercises/complex-numbers/description.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index 2e54752d88..b1f3ff161f 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -37,7 +37,8 @@ The square of the absolute value is computed as the product of `z` and its conju The sum of two complex numbers `z1 = a + b * i` and `z2 = c + d * i` is computed by adding their real and imaginary parts separately: ```text -z1 + z2 = (a + b * i) + (c + d * i) = (a + c) + (b + d) * i +z1 + z2 = (a + b * i) + (c + d * i) + = (a + c) + (b + d) * i ``` ### Subtraction @@ -45,7 +46,8 @@ z1 + z2 = (a + b * i) + (c + d * i) = (a + c) + (b + d) * i The difference of two complex numbers is obtained by subtracting their respective parts: ```text -z1 - z2 = (a + b * i) - (c + d * i) = (a - c) + (b - d) * i +z1 - z2 = (a + b * i) - (c + d * i) + = (a - c) + (b - d) * i ``` ### Multiplication @@ -53,7 +55,8 @@ z1 - z2 = (a + b * i) - (c + d * i) = (a - c) + (b - d) * i The product of two complex numbers is defined as: ```text -z1 * z2 = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i +z1 * z2 = (a + b * i) * (c + d * i) + = (a * c - b * d) + (b * c + a * d) * i ``` ### Reciprocal @@ -61,7 +64,8 @@ z1 * z2 = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i The reciprocal of a non-zero complex number is given by: ```text -1 / z = 1 / (a + b * i) = a / (a^2 + b^2) - b / (a^2 + b^2) * i +1 / z = 1 / (a + b * i) + = a / (a^2 + b^2) - b / (a^2 + b^2) * i ``` ### Division @@ -69,7 +73,9 @@ The reciprocal of a non-zero complex number is given by: The division of one complex number by another is given by: ```text -z1 / z2 = z1 * (1 / z2) = (a + b * i) / (c + d * i) = (a * c + b * d) / (c^2 + d^2) + (b * c - a * d) / (c^2 + d^2) * i +z1 / z2 = z1 * (1 / z2) + = (a + b * i) / (c + d * i) + = (a * c + b * d) / (c^2 + d^2) + (b * c - a * d) / (c^2 + d^2) * i ``` ### Exponentiation @@ -77,7 +83,8 @@ z1 / z2 = z1 * (1 / z2) = (a + b * i) / (c + d * i) = (a * c + b * d) / (c^2 + d Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: ```text -e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) +e^(a + b * i) = e^a * e^(b * i) + = e^a * (cos(b) + i * sin(b)) ``` ## Implementation Requirements From 06a72422bc3b4776d0ddcb7958d69125c4672ea1 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 19 Nov 2024 23:47:08 +0530 Subject: [PATCH 18/18] Updating description for complex-number to fix formatting errors --- exercises/complex-numbers/description.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/complex-numbers/description.md b/exercises/complex-numbers/description.md index b1f3ff161f..63e1ccdb36 100644 --- a/exercises/complex-numbers/description.md +++ b/exercises/complex-numbers/description.md @@ -37,7 +37,7 @@ The square of the absolute value is computed as the product of `z` and its conju The sum of two complex numbers `z1 = a + b * i` and `z2 = c + d * i` is computed by adding their real and imaginary parts separately: ```text -z1 + z2 = (a + b * i) + (c + d * i) +z1 + z2 = (a + b * i) + (c + d * i) = (a + c) + (b + d) * i ``` @@ -46,7 +46,7 @@ z1 + z2 = (a + b * i) + (c + d * i) The difference of two complex numbers is obtained by subtracting their respective parts: ```text -z1 - z2 = (a + b * i) - (c + d * i) +z1 - z2 = (a + b * i) - (c + d * i) = (a - c) + (b - d) * i ``` @@ -55,7 +55,7 @@ z1 - z2 = (a + b * i) - (c + d * i) The product of two complex numbers is defined as: ```text -z1 * z2 = (a + b * i) * (c + d * i) +z1 * z2 = (a + b * i) * (c + d * i) = (a * c - b * d) + (b * c + a * d) * i ``` @@ -64,7 +64,7 @@ z1 * z2 = (a + b * i) * (c + d * i) The reciprocal of a non-zero complex number is given by: ```text -1 / z = 1 / (a + b * i) +1 / z = 1 / (a + b * i) = a / (a^2 + b^2) - b / (a^2 + b^2) * i ``` @@ -73,8 +73,8 @@ The reciprocal of a non-zero complex number is given by: The division of one complex number by another is given by: ```text -z1 / z2 = z1 * (1 / z2) - = (a + b * i) / (c + d * i) +z1 / z2 = z1 * (1 / z2) + = (a + b * i) / (c + d * i) = (a * c + b * d) / (c^2 + d^2) + (b * c - a * d) / (c^2 + d^2) * i ``` @@ -83,7 +83,7 @@ z1 / z2 = z1 * (1 / z2) Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula: ```text -e^(a + b * i) = e^a * e^(b * i) +e^(a + b * i) = e^a * e^(b * i) = e^a * (cos(b) + i * sin(b)) ```