# Laplace, Wave, and Heat

## Solutions for PDE handout #9

### Problem 1

First,  let us recall the formula:

For any function f on the interval [-Pi, Pi], the sum of the first N terms of the Fourier series is given by:

#### 1.a

Let

and

Let us graph these functions to see what they look like

Now, using the above formulas, we can compute the fourier series for these two functions, for any value of N. For instance:

You can find higher oreder series by replacing "5" by a bigger number (if you do this on Macintosh, you should be prepared to wait). We can also compute the series for g(x):

Since the above is zero let us try a bigger number.

Note that if you replace "10" by any higher number, then you will get the exact same thing. This is due to the tignometric identitiy: cosA sinB=1/2[sin(A+B)-sin(A-B)].

#### 1.b

If you have a fast machine, you may execute the following command to gerate all four required graphs

Here I will generate only the first two.

Similarly, we can generate the graphs for g:

The first two are going to be zero, and the next two coincide exactly with the graph of g. See the comment at the end of 1.a.

#### 1.c

Here is how you can find the errors. Let

So the value of the error is large for the first series of f. However, as you can check for yourselves, the error goes down sharply as gets larger.

Similarly, you can set

and plot it to see the maximium for the erroe. Of course, once N gets larger than 9, the error for g will be zero. See the comments at the end of 1.a.

#### 1.d

The reason that they are both sine series is that both functions f and g are odd.

#### 1.e

Both series converge uniformly because f and g are smooth and periodic.

### Problem 2

Here we can use the formulas from the previous handout (Solving the Laplace's equation):

where

and the coefficients A1,..., A4 are :

#### 2.c

By the maximum principle, the oscilation of the function cannot be greater than the oscillation on the boundary. Hence, it is enough to control the error over the boundary.

#### 2.d

As you can see from "SetOptions" in part 2.a, I have set "PlotRange->All". Hence, our graphs
are not going to get clipped. Hence, by looking at the pictures, we can tell what the range is. Without looking at the graphs, it is still easy to figure out what the range should be. All we need is to calculate  the maximium and minimums of f and g over the interval [-Pi, Pi]. By looking at the graphs for f and g (in section 1.a) it is clear what the approximate answer is.

#### 2.e

As you can see, the chosen grid size works fine for both pictures above. The value I have chosen is 40x40, see the "SetOptions" in 2.a.

#### 2.f

In order to see how many points we need, to keep the error less than 0.1, first we need to figure out the size of the increment dx such that |f(x+dx)-f(x)| <= 0.1, for all points x in the interval
[-Pi, Pi]. Suppose we know what dx has tobe. Then all we have to do is to devide [-Pi,Pi] into n segments such that the length of each segment is the same (or smaller) than dx. The length of each segments is 2Pi/n. So we have dx=2Pi/n; or, equivalently,

n=2Pi/dx.

All it remains is to figure out dx. By Taylaors theorem,  f(x+dx)-f(x) <= max(f')dx, where maximum is taken over the interval [-Pi,Pi]. So let us set

dx < 0.1/max(f').

By combining these two formulas we obtain the desired value for n:

n>2Pi max(f')/0.1.

All is left, is to figure out max(f') which is easily done, since the given functions ( f and g) are both elementary. I leave the rest to you.

#### 2.g

Due to the large difference between the scale of the graphs for f an g, the wiggles on the side of the above graph are barely visible. To get a closer look, change the domain:

### Problem 3

The solution to the heat equation u_{xx}=u_t on [0,Pi] x R^+, subject to the boundary conditions u(0,t)=0=u(Pi,t), and u(x,0)=f(x) is given by

where

and (in the interest of time) let us set

The appropraite value for M, i.e. the one which keeps the error under 0.1, may be calculated using the formula for error, see 1.c. For the appropriate size for the grid, see 2.f. Recall also that we do not have to worry about the range since we have set "PlotRange->All".

#### 3.a

Since the above graph decays so fast, let us reduce the time interval to get a better look:

#### 3.b

Again, let us zoom in to get a better look, and a smoother graph:

### Problem 4

#### 4.a

The solution to the wave equation h_{xx}=h_{tt} on [0,Pi]xR^{+}, subject to the boundary conditions h(x,0)=f, h_t(x,0)=g, and h(0,t)=h(Pi,t)=0, is given by

where

and

#### 4.b

As you can see the above picture is not too informative. You can remedy this situation somewhat by increasing the value for "PlotPoints". A n even more helpful option, however, is to flaten the graph. This can be achieved by cnanging the proportions of the box:

Still, you can obtain the best picture by drawing the contour graph
(I got this idea from Boz Wing):

#### 4.c

Another way to generate the above graphs is by solving the wave equation using the characteristic method:

You can check for yourselves that this way we will obtain the same graphs, and we can generate them much more quickly.

Converted by Mathematica      July 3, 2000