Section 28.6 Create A Complex Number Library
Let’s give this a try! We’ll now create our own library, namely a complex number library (note that C does not come with a complex number data type).
A complex number
\begin{equation*}
z = x + iy
\end{equation*}
has a real part x and an imaginary part y. Often, we write z in polar form also as
\begin{equation*}
z = re^{i\phi}
\end{equation*}
where \(r\) is the absolute value (also called magnitude) of the complex number and \(\phi\) is the argument (also called phase of the number).
Again, C does not provide a built-in complex data type (many other languages do), so we must create our own.
Activity 28.3.
Please declare a new datatype complex_t
that stores the real part "real" and the imaginary part "imag" of a complex number as floats.
When you are done, please paste your datatype into the code submission box below: