How one can implement the equation with "$i$" in it?

184 Views Asked by At

I have an equation: $$f(t)=c(e^{i2\pi\frac{n}{T}t}+e^{-i2\pi\frac{n}{T}t})$$ ...for $t\in(-\pi,\pi)$, and with $T=2\pi$. I have to draw a plot of the function $f(t)$ for $n\in\left \{0,1,2,5 \right \}$. But my question is - how can I express $i$ and $-i$ in my code (I'm writing in Python)? What is e.g the total value of the power $i2\pi\frac{n}{T}t$ for $n=1$ and $T=2$?

Thank you in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

Using $$ \cos(\theta) = \frac{\mathrm{e}^{i\theta} + \mathrm{e}^{-i\theta}}{2} $$ I can rewrite your equation as $$ f(t) = 2c\cos\left(2\pi\frac{n}{T}t\right) $$ which is easier to plot, no?

As for the power calculation, what you have written doesn’t make sense. You can compute the power of $f(t)$ as $$ \int_{\Omega} |f(t)|^2dt $$ where $\Omega$ is the domain of interest.

0
On

Use $e^{ix}=\cos x+i\sin x$ and compute the real and imaginary parts separatedly. Note that the imaginary parts cancel out.