Challenge - 5 Problems
Complex Type Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of complex number arithmetic
What is the output of this R code when adding two complex numbers?
R Programming
z1 <- 3 + 4i z2 <- 1 - 2i result <- z1 + z2 print(result)
Attempts:
2 left
💡 Hint
Remember to add real parts and imaginary parts separately.
✗ Incorrect
Adding complex numbers means adding their real parts and imaginary parts separately: (3+1) + (4-2)i = 4+2i.
❓ Predict Output
intermediate2:00remaining
Result of complex conjugate function
What does the following R code print?
R Programming
z <- 5 - 7i conj_z <- Conj(z) print(conj_z)
Attempts:
2 left
💡 Hint
The conjugate of a complex number flips the sign of the imaginary part.
✗ Incorrect
The conjugate of 5 - 7i is 5 + 7i because only the imaginary part changes sign.
❓ Predict Output
advanced2:30remaining
Output of complex division
What is the output of this R code dividing two complex numbers?
R Programming
z1 <- 2 + 3i z2 <- 1 - 1i result <- z1 / z2 print(round(result, 2))
Attempts:
2 left
💡 Hint
Divide complex numbers by multiplying numerator and denominator by the conjugate of the denominator.
✗ Incorrect
Dividing (2+3i) by (1-1i) results in (-0.5+2.5i) after simplification.
🧠 Conceptual
advanced1:30remaining
Understanding complex number modulus
What does the R function Mod() return when applied to a complex number?
Attempts:
2 left
💡 Hint
Think about how far the point is from zero on the complex plane.
✗ Incorrect
Mod() returns the magnitude or absolute value of the complex number, which is the distance from the origin.
🔧 Debug
expert2:30remaining
Identify the error in complex number creation
Which option will cause an error when trying to create a complex number in R?
R Programming
z <- complex(real = 3, imaginary = 4)
Attempts:
2 left
💡 Hint
Check the exact argument names for the complex() function in R.
✗ Incorrect
The argument 'imag' does not exist; the correct argument name is 'imaginary'. Using 'imag' causes an error.