# Solution of Heat Equation Through Fourier Series.

OK, so I was trying to solve the Heat Equation with Inhomogeneous boundary conditions for a rod through Fourier Series when I got stuck at the solution for the coefficient $$c_n$$, the part where I'm stuck is highlighted in red.

The following is just a step-by-step solution of how I got to $$c_n$$.

Heat Equation

$$\alpha^2 \frac{\partial^2}{\partial x^2}u(x,t) = \frac{\partial}{\partial t}u(x,t)$$

Initial Conditions

1. $$u(0,t) = T_1 = 20,\ u(30,t) = T_2 = 50,\ \forall \ t > 0$$

2. $$u(x,0) = 60 - 2x \ \forall \ 0 < x < 30$$

3. $$\alpha^2 = 1$$

Solution

So the general solution would be the steady-state temperature $$v(x)$$ plus the transient temperature $$w(x,t)$$ such as

$$u(x,t) = v(x) + w(x,t)$$

I found out that

$$v(x) = 20 + x$$

$$f(x) = u(x,0) + v(x) = w(x,0) + v(x) = 80 - x$$

Then by evaluating the general expression for the nonhomogeneous heat equation I got to

$$u(x,t) = T_1 + (T_2 - T_1)\frac{x}{L} + \sum_{n=1}^{+\infty} c_n e^{-\frac{n^2 \pi^2 \alpha^2}{L^2}t} sin(\frac{n \pi x}{L})$$

Where

$$c_n = \frac{2}{L}\int_{0}^{L} [f(x) - (T_2 - T_1)\frac{x}{L} - T_1] sin(\frac{n \pi x}{L}) dx$$

My struggling begins here, at $$c_n$$, let's evaluate it.

By using the initial conditions it can be rewritten as

$$c_n = \frac{1}{15}\int_{0}^{30} (60 - 2x) sin(\frac{n \pi x}{30}) dx$$

I'll break it into two integrals as follows

$$c_n = \frac{1}{15}\int_{0}^{30} 60 sin(\frac{n \pi x}{30}) dx - \frac{1}{15}\int_{0}^{30} 2x sin(\frac{n \pi x}{30})dx$$

$$c_n = (I) + (II)$$

Let's solve the integrals separately, solving (I) first

$$(I) = 4 \int_{0}^{30} sin(\frac{n \pi x}{30}) dx$$

$$(I) = \frac{120}{n \pi}(-cos(n \pi) + 1)$$

Now here, I can consider two solutions, (I) = 0 for n ''even'' or (I) = $$\frac{240}{n \pi}$$ for n ''odd''.

Now, solving (II)

$$(II) = \frac{2}{15}\int_{0}^{30} x sin(\frac{n \pi x}{30}) dx$$

$$(II) = \frac{120}{n \pi}(\frac{sin(n\pi)}{\pi} - cos(n \pi))$$

Now, $$sin(n\pi) = 0$$ for n ''odd'' or ''even'', therefore the solution of (II) becomes

$$(II) = \frac{120}{n \pi}( - cos(n \pi))$$

Which will be $$\frac{120}{n \pi}$$ for n ''odd'' or $$-\frac{120}{n \pi}$$for n ''even''.

So as you can see, I have two possible solutions for $$c_n$$ which happens when either n is ''odd'' or ''even'', my question is, which one should I consider? The one for all n ''odd'' or the one for all n ''even''?

Like, if I carry on I would eventually get to

For all n ''odd'':

$$c_n = (I)_{odd} + (II)_{odd}$$

$$c_n = \frac{120}{n\pi}$$

$$u(x,t) = (20 + x) + \frac{120}{\pi}\sum_{n=1,3,5,...}^{+\infty} \frac{1}{n} e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30})$$

For all n ''even'':

$$c_n = (I)_{even} + (II)_{even}$$

$$c_n = -\frac{120}{n\pi}$$

$$u(x,t) = (20 + x) - \frac{120}{\pi}\sum_{n=2,4,6,...}^{+\infty} \frac{1}{n} e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30})$$

So which solution should I use? The one for the n ''odd'' or the one for n ''even''?

Last edited:

Related Calculus and Beyond Homework Help News on Phys.org
How it is that your two different conditions give one u(0,0)=20 and the second one u(0,0)=60?

How it is that your two different conditions give one u(0,0)=20 and the second one u(0,0)=60?
They don't.

For $$u(x,0) = 60 - 2x$$

we have 0 < x < 30

and for $$u(0,t) = 20$$

we have t > 0.

I guess I haven't specified it very clear in the initial conditions on the original post, I'll edit that.

Here's the problem:

[PLAIN]http://img3.imageshack.us/img3/4238/ff212.jpg [Broken]

Last edited by a moderator:
From (19) you have discontinuity at x=0? For t=0 you have u(0+,0)=60-0=60
And for t>0 you have u(0,t)=20. Just checking ...

Last edited:
As for your odd-even problem: why don't you use odd solution for odd n and even solution for even n? I do not get it. After all you have to sum over n from 1 to infinity.....

Hey, I think I've got it, listen

For all n ''odd'':

$$c_n = (I)_{odd} + (II)_{odd}$$

$$c_n = \frac{120}{n\pi}$$

$$u(x,t) = (20 + x) + \frac{120}{\pi}\sum_{n=1,3,5,...}^{+\infty} \frac{1}{n} e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30})$$

For all n ''even'':

$$c_n = (I)_{even} + (II)_{even}$$

$$c_n = -\frac{120}{n\pi}$$

$$u(x,t) = (20 + x) - \frac{120}{\pi}\sum_{n=2,4,6,...}^{+\infty} \frac{1}{n} e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30})$$

So which solution should I use? The one for the n ''odd'' or the one for n ''even''?
$$\frac{1}{n} e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30})$$

is an even function right?

As both

$$(\frac{1}{n}e^{-\frac{n^2 \pi^2}{900}t})$$ and $$sin(\frac{n \pi x}{30})$$ are odd functions, their product is an even function and therefore, for even functions

$$f(-x) = f(x)$$

So I guess

$$\frac{120}{\pi}\sum_{n=1,3,5,...}^{+\infty} \frac{1}{n} e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30}) = \frac{120}{\pi}\sum_{n=2,4,6,...}^{+\infty} (\frac{-1}{n}) e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30})$$

And therefore as both solutions are equal for all n I can rewrite it as

$$u(x,t) = (20 + x) + \frac{60}{\pi}\sum_{n=1}^{+\infty} \frac{1}{n} e^{-\frac{n^2 \pi^2}{900}t} sin(\frac{n \pi x}{30})$$

What do you say? Is this acceptable?

Last edited:
I do not understand what you are doing. You have 0<x<30, so the question of even-odd functions should not even arise. The exponential is a constant function (as a function of x), why you call it odd? Why don't you just add two sums, one for n even, one for n odd, including your (I) and (II) and simplifying according to the case?

I do not understand what you are doing. You have 0<x<30, so the question of even-odd functions should not even arise. The exponential is a constant function (as a function of x), why you call it odd? Why don't you just add two sums, one for n even, one for n odd, including your (I) and (II) and simplifying according to the case?
Oh, you're right, what was I doing? :tongue: Never mind the previous post. I guess I'll just add the two sums then.

LCKurtz
Homework Helper
Gold Member
You started with the substitution

u(x,t) = v(x) + w(x,t)

This will give you w(x,0) = u(x,0) - v(x). You have correctly determined that v(x) = 20 + x so you should have

w(x,0) = 60 - 2x - (20 + x) = 40 - 3x.

It looks to me like you are copying a general answer from a text instead of understanding what you are doing. You should be solving the W system:

wxx(x,t) = wt(x,t)
w(0,t) = 0, w(0,30) = 0
w(x,0) = 40 - 3x.

Once you get w(x,t) you will add v(x) to it to get the solution. Eventually you should come to the fourier series

$$40 - 3x = \sum_{n = 1}^{\infty}b_n\sin\frac{n\pi}{30}x$$

for which you can use the half range sine coefficients. Don't break it into odd and even, just calculate them.