Unformatted text preview:

MATH 5620 NUMERICAL ANALYSIS IIHOMEWORK 4, DUE FRIDAY MARCH 11 2011Problem 1 Consider the Poisson equation∆u = f(x, y) for x ∈ [0, 1] and y ∈ [0, 1]u(x, y) = 0 if x = 0 or x = 1 or y = 0 or y = 1.Withf(x, y) = sin(πx) sin(2πy),the true solution isu(x, y) = −f(x, y)/(5π2).Use the finite difference method with xi= ih, i = 0, . . . , n + 1 andyj= jh, j = 0, . . . , n + 1, for the values n = 10, 50, 100 and h = 1/(n + 1).Compute the maximum absolute error in your approximation and producea log-log plot with h in the abscissa and the error in the ordinate. Is thisplot consistent with the expected O(h2) convergence rate?Notes:– You may find it easier to write the discretization matrix with Matlab’skron (in Octave replace by spkron).See class notes (math5620s11 06.pdf p85)– You may use Matlab’s backslash to solve the system.– Your system matrix should be n2× n2. Think of using matrix opera-tions to put values in lexicographic ordering:x = linspace ( 0 , 1 , n+2) ; y = li nspace ( 0 , 1 , n+2) ;[X,Y] = ndgrid ( x ( 2 : n+1) , y ( 2 : n+1) ) ;utrue = @( x , y ) . . . . % some f u n c t i o nUtrue = u t rue (X,Y) ;The matrix Utrue is n × n and such thatUtrue ( i , j ) = u true ( x ( i + 1) , y ( j +1) )Since the vector Utrue(:) contains the columns of Utrue concate-nated, it corresponds to ordering the nodes by y and then by x as inthe following example with n = 3 (which includes only the nodes thatare not on the boundary)y ↑7 8 94 5 61 2 3→xwhere the arrows indicate the direction of increasing values of thecorresponding variables.12 MATH 5620 NUMERICAL ANALYSIS II HOMEWORK 4, DUE FRIDAY MARCH 11 2011Problem 2 Consider the parabolic PDE (heat equation)ut= uxxfor t > 0 and x ∈ [0, 1],u(x, 0) = η(x) for x ∈ [0, 1],u(0, t) = u(1, t) = 0 for t > 0,Use the Crank-Nicholson method with the space discretization xi= ih,i = 0, . . . , n + 1, h = 1/(n + 1), n = 100 and time discretization k = 1/1000to approximate the solution for the initial conditions(a) η(x) = sin(πx)(b) η(x) = sin(πx) + sin(10πx)Please include snapshots of both solutions at times t = 2k and t = 5k.Notes:– With these particular boundary conditions the method can be writtenasUn+1= (I − (k/2)A)−1(I + (k/2)A)Unwhere A is the usual finite difference discretization of the 1D Laplacian.– You may use Matlab’s backslash to solve the systems at each


View Full Document

U of U MATH 5620 - Homework 4

Download Homework 4
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework 4 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 4 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?