# Plotting a partial sum with imaginary numbers on exponentials

Exercise

Given Given
$\qquad f(x)=\sum\limits_{n=-\infty}^{\infty}f_{n}e^{i\,n\,x}$
where
$\qquad \left \langle f,g \right \rangle = \frac{1}{2\pi}\int_{-\pi}^{\pi}f\,g^{*}\,dx$

and the $n^{th}$ Fourier coefficient is

$\qquad f_{n} = \left \langle f(x),\,e^{i\,n\,x}\right \rangle$

Plot the partial sum for $n = 1,3,5,9,$ and $15$.

Or in Mathematica Language:

f[x_, n_] := Sum[Subscript[f, n]]Exp[Inx]], {x, -∞, ∞}]


where

〈f, g〉 = 1/(2 π) Integrate[f SuperStar[g], {x, -π, π}]


and the $n^{th}$ Fourier coefficient is

Subscript[f_, n_] := 〈f[x], Exp[I n x]


But note that

$\qquad f(x) = \sum\limits_{n=-\infty}^{\infty} f_{n}e^{i\, n\, x} = 2\sum\limits_{n = 1}^{\infty} f_{n} e^{i\, n\, x}$

Defining

Subscript[f, n] := AngleBracket[f[x], Exp[-I n x]].


The infinite sum can be reduced to

f[x_, n_] := Sum[Subscript[f, n] Exp[I n x], {x, -∞, ∞}]


implies

2 g[x_,n_] := 2 Sum[Subscript[f, n] Exp[I n x], {x, 1, ∞}]


noting that Subscript[f, 0] == 0

The first partial sum is

2 Sum[Subscript[f, n] Exp[I n x], {n, 1, 1}]


I would like to plot this partial sum but the existence of an imaginary number makes it hard to do, given my unfamiliarity with Mathematica.

What is a good way to deal with this?

Any help is appreciated. Thanks in advance.

• You have posted quite a few questions on this site over the last 21 months. You should by now have enough experience of what is considered good practice on the site not to post expressions like f (x) == \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$n = \(-\[Infinity]$$\), $$\ \[Infinity]$$]$$\*SubscriptBox[\(f$$, $$n$$]\ \*SuperscriptBox[$$E$$, $$I\ n\ x$$]\)\), which is neither valid Mathematica code nor MathJaX. Please consider putting more effort in formatting your questions in way that makes them more readable and easier work with. – m_goldberg Jun 3 '17 at 11:11
• Your question is better after the spate of recent edits, but it still falls short of being a well-posed question. Expressions like f(x) = Sum[Subscript[f, n] e^Inx, {x, -∞, ∞}]` are still present and are not valid Mathematica code. Further, they are ambiguous. Do you intend this to represent a relation or definition? As it stands it is neither. – m_goldberg Jun 3 '17 at 15:48
• Looks like a hometask. Is it not? – Alexei Boulbitch Jun 3 '17 at 20:11
• @AlexeiBoulbitch It is. But with the mathematics out of the way by my attempt, I think what is remaining is transmuting what is left on hand into a computational sensible language. Plotting partial sums without imaginary entities is fairly straightforward. The existence of imaginary numbers makes it less obvious as to what should be done. – Physkid Jun 4 '17 at 3:14
• @m_goldberg This edited post should look approximately close to what is required. It probably doesn't matter. I can always redefine a new function after putting the original function through a manipulation. – Physkid Jun 4 '17 at 3:19