# Homework Help: C_0 coefficient of Complex Fourier transforms

1. Nov 8, 2015

### Wminus

Mod note: Moved from technical math section, so no template was used.
Hey! So the complex fourier transform of the square wave

$$f(x) = \begin{cases} 2 & x \in [0,2] \\ -1 & x \in [2,3] \\ \end{cases}, \space \space f(x+3) = f(x)$$

is $C_k = \frac{3j}{2 \pi k}( e^{-j \frac{4 \pi k}{3}} -1)$, correct? However, setting $k = 0$ and using L' Hopital rule I get that $C_0 = 2$, while it should be equal to 1 since that's the average of the function.

Where is the error? My expression for $C_k$ is correct, right?

Last edited: Nov 9, 2015
2. Nov 9, 2015

### Ray Vickson

Are actually doing the Fourier transform, or do you mean the Fourier series? These are very different things.

3. Nov 9, 2015

### Wminus

I'm sorry, I mixed them up. I meant I was finding the the complex fourier series of $f(x)$ , with the $C_k$s being its coefficients.

4. Nov 10, 2015

### Ray Vickson

OK, so to clarify: are you writing the Fourier series as
$$f(x) = \sum_{n=-\infty}^{\infty} c_n e^{inax}$$
for an appropriate value of the parameter $a$? If so, what is your $a$, and what is the formula you are using to compute the $c_n$?

5. Nov 10, 2015

### Wminus

Sorry, it appears my OP was really ****. Yeah, I am using that form and I use equation 3 from here http://www.thefouriertransform.com/series/complexcoefficients.php to calculate the fourier coefficients. What I don't get is why my C_0 coefficient is twice as large as it's supposed to be..

6. Nov 10, 2015

### Ray Vickson

That's odd: when I do the integral, I get $c_0 = \frac{1}{3} \int_0^3 f(t) \, dt = 1$, not the value 2 that you claim. I have not checked your other values for $n \neq 0$.

Last edited: Nov 10, 2015
7. Nov 10, 2015

### Wminus

Yes, I get that too. That is the correct value. My problem is that I don't get this result with the expression of the $C_k$ from the OP.

I'll try to explain my problem as best I can:

(1) I got my $C_k=\frac{3j}{2 \pi k}( e^{-j \frac{4 \pi k}{3}} -1)$ from the definition of the complex-fourier series, and that definition states: $C_k = \frac{1}{T} \int_0^T f(t) e^{-j k \omega t} dt, \space \omega = 2 \pi /T$. This is defined for all $k \geq 0$, right?

(2) Further, by setting $k=0$, we get that $C_0 = \frac{1}{T} \int_0^T f(t) e^{-j k \omega t} dt$, which is $C_0 =1$ in our case.

However, from my earlier expression (1), I have that setting $k=0$ gives $lim_{k\to0} C_k = lim_{k\to0} \frac{3j}{2 \pi k}( e^{-j \frac{4 \pi k}{3}} -1) = 2 \neq 1$. This isn't what I get in (2), and I fail to understand this discrepancy!

8. Nov 11, 2015

### Ray Vickson

The problem seems to be that for $k \neq 0$ there are different ways of writing $C_k$ that are all the same as your expression when $k$ is an integer. For example, when I compute $C_k$ for general $k > 0$ using Maple, I get
$$C_k = \frac{i}{2 \pi k} \left( -2 + 3e^{-4 \pi i k/3} - e^{-2 \pi i k} \right)$$
This expression has limit $\lim_{k \to 0} C_k = 1$, as it should (from continuity of $e^{- i k 2 \pi/3}$). When $k$ is an integer, it reduces to your previous expression for $C_k$, but that expression does not apply when $k$ is fractional.

9. Nov 11, 2015

### Wminus

Kind of interesting how all this weird stuff starts happening when you start dividing by zero... When I derived $C_k$ I made no assumptions what-so-ever, so both mine and your $C_k$ should be mathematically equivalent to $C_k = \frac{1}{T} \int_0^T f(t) e^{-j k \omega t} dt, \space \omega = 2 \pi /T$. Yet despite this, they produce different answers. Strange.

But at the end of the day L'Hopital's rule is used to evaluate these limits and I've only ever applied it when the variable of differentiation is continuous, while here $k$ is discrete.

10. Nov 11, 2015

### Ray Vickson

Well, my $C_k$ above IS $\frac{1}{T} \int_0^T f(t) e^{-j \omega k t}\, dt$ without any assumptions about $k$. However, the moment you make $k$ an integer, you can (and often will) make $e^{-2 \pi i k} = 1$ automatically; for example, most (or, at least, many) computer algebra systems will make that simplification right away, and that will be enough to change the limit.

Basically, it amounts to saying that $C_k = N(k)/k$, and that we can have two different numerator functions $N_1(k)$ and $N_2(k)$ such that $N_1(k) = N_2(k)$ for all integers $k$, but with different derivatives $N_i'(k)$ at the integer values of $k$. That will make the limits of $N_1(k)/k$ and $N_2(k)/k$ come out different as $k \to 0$.

11. Nov 11, 2015

### Wminus

Ah yes, you're right. I think I also set $e^{-2 \pi i k} = 1$ in my calculations, unwittingly making the mathematical assumption that the $k$s are integers, and thus changed the limit that comes from L'Hopital. I didn't realize the assumption I made because I thought it was a given that the $k$s are integers, but just looking at the definition of $C_k$ I see it wasn't.

Thanks man, I really appreciate that you cleared this up for me. :)