BACKGROUND / MOTIVATION:
Complex numbers can be an important tool in an electrical engineer's toolbox because they can help us describe / work with sinusoidal signals.
Sinusoidal signals can be found all over the place in day-to-day life (in music, light, communication systems, power systems, etc.):
When working with complex numbers, sometimes it's easier to work with the "rectangular/Cartesian form" (z = x + j*y) and sometimes it's easier to work with the "polar form" (r ∠ θ).
Write a function which converts between the rectangular form and the polar form.
You can view a comparison of the two forms here: https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers
The variable "form" will be used to determine whether the function converts from rectangular to polar or from polar to rectangular.
The function takes the following inputs:
The function will output the variable "output" in the form of a column vector [output1;output2] where:
The test suite will round the components of your output vector to 4 decimal places.
Please feel free to leave feedback on this problem in the comments! :)