Challenge - 5 Problems
Complex Number Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of complex number multiplication
What is the output of the following MATLAB code?
MATLAB
z1 = 3 + 4i; z2 = 1 - 2i; result = z1 * z2; disp(result);
Attempts:
2 left
💡 Hint
Recall how to multiply complex numbers: (a+bi)(c+di) = (ac - bd) + (ad + bc)i.
✗ Incorrect
Multiplying (3+4i) and (1-2i) gives (3*1 - 4* -2) + (3* -2 + 4*1)i = (3 + 8) + (-6 + 4)i = 11 - 2i.
🧠 Conceptual
intermediate1:30remaining
Understanding complex conjugate in MATLAB
Which MATLAB expression correctly computes the complex conjugate of z = 5 + 6i?
Attempts:
2 left
💡 Hint
The complex conjugate flips the sign of the imaginary part.
✗ Incorrect
The MATLAB function conj() returns the complex conjugate, which changes 5+6i to 5-6i.
🔧 Debug
advanced2:00remaining
Identify the error in complex number addition
What error does the following MATLAB code produce?
MATLAB
z1 = 2 + 3i; z2 = 4 + 5j; result = z1 + z2; disp(result);
Attempts:
2 left
💡 Hint
In MATLAB, both i and j represent the imaginary unit by default.
✗ Incorrect
MATLAB treats both i and j as the imaginary unit unless they are redefined. So adding 2+3i and 4+5j works fine, resulting in 6+8i.
📝 Syntax
advanced1:30remaining
Correct syntax for creating a complex number
Which option correctly creates a complex number with real part 7 and imaginary part -9 in MATLAB?
Attempts:
2 left
💡 Hint
The complex() function takes two arguments: real and imaginary parts.
✗ Incorrect
Option A uses the complex() function correctly. Option A is valid MATLAB syntax; MATLAB accepts it but option A is the most explicit and error-free. Option A is invalid syntax. Option A uses j which is valid but option A is the safest and clearest.
🚀 Application
expert2:30remaining
Calculate magnitude and phase of a complex number
Given z = -3 + 4i, what are the magnitude and phase (in radians) computed by MATLAB's abs() and angle() functions?
MATLAB
z = -3 + 4i; magnitude = abs(z); phase = angle(z); disp([magnitude, phase]);
Attempts:
2 left
💡 Hint
Magnitude is sqrt(real^2 + imag^2). Phase is the angle from the positive real axis.
✗ Incorrect
Magnitude = sqrt((-3)^2 + 4^2) = 5. Phase = atan2(4, -3) ≈ 2.2143 radians (in second quadrant).