| description | | hints | | solution | | discussion |
| list of all exercises | |||
In the file Complex.h (*) you find the class Complex as discussed in the last lecture. Extend the class with two new methods:
| a) | norm: | Returns the norm (a*a + b*b) of a complex number (a,bi) |
| b) | arg: | Returns the phase of a complex number (a,bi) given by atan2(b,a) |
Also implement two new global functions:
| c) | conj: | Returns the conjugate (a,-bi) of a complex number (a,bi) |
| d) | polar: | Constructs a complex number from its amplitude mag
and phase arg (polar coordinates): real part := cos(arg) * mag imaginary part := sin(arg) * mag |
The program test2.cpp (*) can be used for testing.