Homework #1. (Due Sept. 10) Math. 610:601 (Last modified on 2015-09-09 16:54) This assignment involves setting up a finite difference code which can be applied to −∆u = f, in Ω ⊂ [−1, 1]2 , u(x) = g(x), for x ∈ ∂Ω. We shall assume that ∂Ω lines up with the finite difference mesh. We shall use the same mesh size h = 1/N in each coordinate direction. The domain Ω is then determined by its interior nodes, i.e. Ω = interior(∪S̄i,j ) with Si,j denoting the square of size 2h having xij = h(i, j) as its center and the union is over the interior nodes (i, j). In the implementation, we assume an indicator function ISINTERIOR(i,j) which returns true (1) when i, j corresponds to an interior point and false (0) otherwise. The first task of the code is to use the indicator function to order and identify, interior and non-interior nodes. The interior nodes are a subset of I := {(i, j), i, j = −N, −N + 1, . . . , N − 1, N }. Using ISINTERIOR, and looping through all (i, j) ∈ I, you need to build two arrays: ( 0: if (i, j) is not interior, ISN ODE(i + (j − 1) ∗ (2N + 1)) = ℓ: if (i, j) is interior. Here ℓ is the interior node number sequentially assigned as you loop through all (i, j) pairs. As you build ISN ODE you need to also construct its inverse, namely the array P air(ℓ) = (ii(ℓ), jj(ℓ)) with ii(ℓ), jj(ℓ) equal to the coordinate index corresponding to interior node ℓ. The next two examples will illustrate the convergence behavior of finite differences applied to two problems on the domain Ω = (−1, 1)2 \[0, 1] × [−1, 0]. In these examples, we will know the analytic solution (given by g(x1 , x2 )) and so we can compute the error between the approximate and analytic solutions. Of course, you will also need to use g to evaluate the boundary data. You need to write an indicator function for this domain. 1 2 Problem 1. Take f = −4 and g(x1 , x2 ) = x21 +x22 . Run a sequence of meshes corresponding to N = 4, 8, 16, 32, 64. For each mesh report the errors 1/2 X 2 kek∞ = max |e(i,j) | and kekℓ2 = h . |e(i,j) | (i,j) (i,j) Here the max and sum are take over interior nodes. Problem 2. Take f = 0 and g(x) = r2/3 sin(2θ/3) with r,θ denoting the radial coordinates of x. Run a sequence of meshes corresponding to N = 4, 8, 16, 32, 64. Report the resulting errors in the norms of the previous problem.