Unformatted text preview:

MATH 5620 NUMERICAL ANALYSIS IIHOMEWORK 5, DUE FRIDAY APRIL 3 2009The goal of this assignment is to use the finite element method with piecewiselinear finite elements to solve the one dimensional BVP(1)(−u00= f,u(0) = u(1) = 0.The weak formulation of the problem is(2) Find u ∈ V s.t. a(u, v) = (f, v), ∀v ∈ V ,where V = {v | ||v||2L2+ ||v0||2L2< ∞ and v(0) = v(1) = 0}.Let xi= (i −1)h, where h = 1/n and i = 1, . . . , n + 1. We subdivide the interval[0, 1] into n elements Ie= [xe, xe+1]. The approximation space for the Galerkinmethod is Vh= {v ∈ V | v|Ie∈ P1}, where P1is the space of polynomials withdegree less than 1. The Galerkin problem is(3) Find uh∈ Vhs.t. a(uh, vh) = (f, vh), ∀vh∈ Vh.As we saw in class, the local to global mapping can be represented as a matrixi = [1:n;2:n+1]’;, where i(e, j) is the global index of the j−th local degree offreedom of element e.1. Assemble the stiffness matrix K ∈ Rn+1×n+1, where Ki,j= a(φi, φj) and the φiare the hat functions (φi(xj) = δij). Do this element by element and store it asa sparse matrix as followsK = sparse ( n+1,n+1) ;for e =1:n ,K( i ( e , : ) , i ( e , : ) ) = K( i ( e , : ) , i ( e , : ) ) + Kloc /( x ( e +1)−x ( e ) ) ;end ;where Kloc=[1 -1;-1 1]; is the local stiffness matrix.2. Assume the right hand side f ∈ Vh, i.e. it is determined by its values at the nodesxi. Write a procedure to assemble element by element the right hand side F ∈Rn+1, where Fj= (f, φj). Just as for the stiffness matrix this should be done as aloop over the elements where the contribution from the current element is addedto the vector F . These integrals are more conveniently evaluated by changingvariables from the current element [xe, xe+1] to the “parent” or reference element[0, 1]. There the integrals can be evaluated exactly by hand.3. The system Ku = F you will obtain is singular because we have not takeninto account the Dirichlet boundary conditions. An easy way of imposing thatu(0) = u(1) = 0 is to hard wire the condition in the equations of the linearsystem:K( 1 , : ) = 0 ; K( 1 ,1) =1;K( n +1 , :) = 0 ; K( n+1,n+1)=1;F( 1 ) =0; F( n+1)=0;12 MATH 5620 NUMERICAL ANALYSIS II HOMEWORK 5, DUE FRIDAY APRIL 3 20094. Solve the problem (1) with n = 10 and n = 100 and f(x) = exp(x) (taking asright hand side for the system Fj= exp(xj)). Plot the numerical solution alongwith the true solution utrue(x) = − exp(x) + (exp(1) − 1)x + 1.5. Do a log-log plot of h and the maximum error between the numerical solutionuhand the true solution utrue, for n = 10, 100, 500, 1000. How does the errorbehave as a function of


View Full Document

U of U MATH 5620 - HOMEWORK 5

Download HOMEWORK 5
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 5 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 5 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?