Complex Numbers
Complex numbers are related to calculus and advanced math and widely used in quantum mechanics, signals processing, and physics.
Since this course aims to teach R basics, we will not dig deep into this subject but only consider this as one of the numerical types. Each complex number consists of real (let it be a
) and imaginary (let it be b
). Then the expression a+bi
is called a complex number. i
- is an imaginary unit such that i^2 = -1
.
To create such a number in R, use the same denotation as above: a + bi
. For example, we can create a complex number with the real part 5
and the imaginary part -3
.
123compl = 5 - 3i # Creating complex number compl # Output the number typeof(compl) # Output its type
The output is:
[1] 5-3i
[1] "complex"
You can perform arithmetic operations learned before with all the number types we have learned in this section.
Swipe to start coding
- Create
integer
number20
assigned to variablenum
. - Create a
complex
number with real part10
and imaginary-5
assigned to variablecompl
. - Perform the addition of
num
andcompl
assigned to variableres
. - Output the type of
res
.
Solution
The result has a "complex"
type since the complex numbers are an extension field of the real numbers (and integers, respectively).
Merci pour vos commentaires !
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Résumer ce chapitre
Expliquer le code dans file
Expliquer pourquoi file ne résout pas la tâche
Awesome!
Completion rate improved to 12.5
Complex Numbers
Glissez pour afficher le menu
Complex numbers are related to calculus and advanced math and widely used in quantum mechanics, signals processing, and physics.
Since this course aims to teach R basics, we will not dig deep into this subject but only consider this as one of the numerical types. Each complex number consists of real (let it be a
) and imaginary (let it be b
). Then the expression a+bi
is called a complex number. i
- is an imaginary unit such that i^2 = -1
.
To create such a number in R, use the same denotation as above: a + bi
. For example, we can create a complex number with the real part 5
and the imaginary part -3
.
123compl = 5 - 3i # Creating complex number compl # Output the number typeof(compl) # Output its type
The output is:
[1] 5-3i
[1] "complex"
You can perform arithmetic operations learned before with all the number types we have learned in this section.
Swipe to start coding
- Create
integer
number20
assigned to variablenum
. - Create a
complex
number with real part10
and imaginary-5
assigned to variablecompl
. - Perform the addition of
num
andcompl
assigned to variableres
. - Output the type of
res
.
Solution
The result has a "complex"
type since the complex numbers are an extension field of the real numbers (and integers, respectively).
Merci pour vos commentaires !
Awesome!
Completion rate improved to 12.5single