Assignment title: Information


Problem: Finite Differences and Robin Conditions In class we said that to have a quadratic order of accuracy solving ODEs using the finite difference approximation, we had to approximate the first order derivative using centered differences. But how does this works in reality? Let us consider the Cauchy Euler equation for y as a function of t (i.e. y = y(t)): t2y00 + ty0 = 4y (1) This equation is really popular when we are dealing with an elliptic equation in polar coordinates and we apply separation of variables. The goal of this homework is to see how the discretization of the first derivative affects the whole error Part 1: Dirichlet Boundary Conditions 1. First, let us find the analytical solution of 8><>: t2y00 + ty0 = 4y 2 ≤ t ≤ 4 y(2) = 1 y(4) = 1 (2) As a hint, first find 2 solutions for the general ODE in (1). It is known that each of the solutions should have shape y = tk, where k is a number that you should find using (1). Once you have the general solutions y1 and y2 then the particular solution is y = A∗y1+B∗y2 where A and B are constants that are chosen such that the boundary conditions in (2) are satisfied. 2. Now implement a function that receives N, and returns the approximate value of y at the points t0; t1; t2; :::; tN−1; tN, using finite differences to solve the Boundary Value problem (2). Discretize y0 using centered finite differences, and y00 with the standard second order approximation. 3. Implement a function that receives N, and returns the approximate value of y at the points t0; t1; t2; :::; tN−1; tN, using finite differences to solve the Boundary Value problem (2). Discretize y0 using forward finite differences in t, and y00 with the standard second order approximation. 14. Solve (2) for N 2 [5; 10; 20; 50; 100; 500; 1000] and plot the infinity norm of the error per N, i.e. eN = max i=0:N jyi − y(ti)j using method in 2. and in 3., and comparing with the exact solution in 1. How is the error for the methods in 2. and 3.? How can you explain this? Part 2: Robin Boundary Conditions 5. First, let us find the analytical solution of 8><>: t2y00 + ty0 = 4y 2 ≤ t ≤ 4 y(2) + y0(2) = 0:4 y(4) − 2y0(4) = 0:4 (3) Since the equation is the same as in part 1, you can use the general solutions you found in 1. The only step that could change is finding the constants, so now we need to find A and B such that y = A ∗ y1 + B ∗ y2 satisfies the boundary conditions at (3), where y1 and y2 are general solutions of (1). 6. Now implement a function that receives N, and returns the approximate value of y at the points t0; t1; t2; :::; tN−1; tN, using finite differences to solve the Boundary Value problem (3). Discretize y0 using centered finite differences, and y00 with the standard second order approximation. Notice that the only rows of the system that will change (with respect to 2.) are the corresponding to y0 and yf . Include the Robin conditions using fictitious points t−1 and tN+1 and approximating the first derivatives with centered differences. 7. Repeat the previous point 6., but include the Robin conditions approximating the first derivatives with only 2 points, this means that in i = 0 use Forward differences (y1 and y0); and in i = 0 use Backward differences (yN−1 and yN). Notice that in this case, you can place directly the Robin conditions in the linear system of equations (without using fictitious points) 8. Solve (3) for N 2 [5; 10; 20; 50; 100; 500; 1000] and plot the infinity norm of the error per N, i.e. eN = max i=0:N jyi − y(ti)j using method in 6. and in 7., and comparing with the exact solution in 5. How is the error for the methods in 6. and 7.? How can you explain this? 2