By Mark S. Gockenbach (siam, 2010)


Section 8.2: First-order quasi-linear PDEs



Download 2.45 Mb.
Page18/25
Date09.06.2018
Size2.45 Mb.
#53772
1   ...   14   15   16   17   18   19   20   21   ...   25

Section 8.2: First-order quasi-linear PDEs

The purpose of the method of characteristics is to reduce a PDE to a family of ODEs. MATLAB has a function called dsolve that will solve many ordinary differential equations symbolically. I will illustrate the use of dsolve in the context of Example 8.6 (pages 323-324 in the text):


Example 8.6

The method of characteristics reduces the given PDE to the IVP



dsolve will solve this problem as follows:
dsolve('Dv=v^2','v(0)=1/(1+s^2)')

ans =


1/(s^2 - t + 1)
There are several points to notice about the use of dsolve:
The differential equation is specified as a string, in (single) quotation marks, and it is followed by the initial condion(s) (if any), also in single quotes. Notice that, unlike with the solve command, there is no option to give the equation explicitly using symbolic variables, rather than as a string. dsolve determines the name of the unknown function from the equation, and assumes that the independent variable is t.
Any derivatives are specified using "D" as an operator. If a higher-order derivative appears, it is specified using "D2", "D3", etc. For example:

dsolve('D2x=-x','x(0)=0','Dx(0)=1')

ans =

sin(t)
If no initial condition is given, dsolve returns the general solution of the ODE (when possible):




dsolve('Dv=v^2')

ans =


0

-1/(C13 + t)


Notice that, in this example, two solutions are returned. This is because the formula does not include the special solution . This situation is always possible when the differential equation is nonlinear. Also notice that MATLAB chose a name for the constant in the general solution. If it solves another problem, it will choose another name for the constant:
dsolve('Dv=v')

ans =


C16*exp(t)
If desired, you can give dsolve a different name for the independent variable; this has to be the final input:
dsolve('Dv=v^2','x')

ans =


0

-1/(C19 + x)


dsolve will solve a system of ODEs (when possible); the equations in the system are given as multiple inputs to dsolve. This is illustrated in the context of Example 8.7 (pages 325-326 in the text):

Example 8.7

The method of characteristics, applied to the given PDE, yields the following system of ODEs:


dx/dt=v, x(0)=s,

dy/dt=y, y(0)=1,

dv/dt=x, v(0)=2s.
We solve this as follows:
sol=dsolve('Dx=v','Dy=y','Dv=x','x(0)=s','y(0)=1','v(0)=2*s')

sol =


y: [1x1 sym]

x: [1x1 sym]

v: [1x1 sym]

sol.x

ans =

(3*s*exp(t))/2 - s/(2*exp(t))



sol.y ans =

exp(t)


sol.v

ans =


s/(2*exp(t)) + (3*s*exp(t))/2

Chapter 11: Problems in multiple spatial dimensions




Section 11.2: Fourier series on a rectangular domain

Fourier series calculations on a rectangular domain proceed in almost the same fashion as in one-dimensional problems. The key difference is that we must compute double integrals and double sums in place of single integrals and single sums. Fortunately, this is not difficult, since a double integral over a rectangle is just an iterated integral.


As an example, I will compute the Fourier double sine series of the following function f on the unit square:
clear

syms x y

f=x*y*(1-x)*(1-y)

f =


x*y*(x - 1)*(y - 1)
The Fourier series has the form

where amn is computed as follows:
syms m n pi

a=4*int(int(f*sin(m*pi*x)*sin(n*pi*y),y,0,1),x,0,1)

a =

(4*(16*cos((pi*m)/2)^2*cos((pi*n)/2)^2 + 8*pi*n*sin((pi*n)/2)*cos((pi*m)/2)^2*cos((pi*n)/2) - 16*cos((pi*m)/2)^2 + 8*pi*m*sin((pi*m)/2)*cos((pi*m)/2)*cos((pi*n)/2)^2 + 4*pi^2*m*n*sin((pi*m)/2)*sin((pi*n)/2)*cos((pi*m)/2)*cos((pi*n)/2) - 8*pi*m*sin((pi*m)/2)*cos((pi*m)/2) - 16*cos((pi*n)/2)^2 - 8*pi*n*sin((pi*n)/2)*cos((pi*n)/2) + 16))/(pi^6*m^3*n^3)


Here is the partial Fourier series with a total of 100 terms:
S=symsum(symsum(a*sin(m*pi*x)*sin(n*pi*y),n,1,10),m,1,10);

To graph the (partial) Fourier series, I begin by creating, the two one-dimensional grids:


xx=linspace(0,1,21)';

yy=linspace(0,1,21)';


Next, I invoke meshgrid to create the two-dimensional grid:
[X,Y]=meshgrid(xx,yy);
Finally, I compute the function f, from the previous example, on the grid:
Z=subs(f,{x,y},{X,Y});

(Notice how I can substitute for two variables at one time by listing the variables and the values between curly brackets.)


Now I invoke the surf command:
surf(X,Y,Z)


I can also evaluate the Fourier series on the two-dimensional grid. Notice that this may take some time if the grid is very fine or there are many terms in the series, or both.
Z1=subs(S,{x,y},{X,Y});

surf(X,Y,Z1)




Here is the approximation error:
surf(X,Y,Z-Z1)


Looking at the vertical scale on the last two plots, we see that the error of approximation is only about one-half of one percent.


Download 2.45 Mb.

Share with your friends:
1   ...   14   15   16   17   18   19   20   21   ...   25




The database is protected by copyright ©ininet.org 2024
send message

    Main page