HI, in this segment, we'll be finishing up the template for the first coding assignment. We'll look at the solve and output results functions, and especially we'll be looking at the L2 norm of error function. Okay, so let's move over here to the code. Solve you can see is a very short function. We first create this SparseDirectUMFPACK object A. Again it's also like a sparse matrix, but it's set up for a particular solver which is the UMF pack solver, okay? Now this A we initialize with our global matrix K. Again we've already applied the under conditions, we've already populated it from K local. And now we're going to do A.vmult D and F. What that is doing is D is = to K inverse times F, okay. I just want to point out here in the future when we are doing some matrix spectrum multiplications we will use dot vmult with DL2's full matrix data type. Just want to point out that here with SparseDirectUMFPACK.vmult does a matrix inverse times a vector. But in the future one we're dealing with just the DL2 full matrix and DL2 vector dot vmult simply does a matrix vector multiplication without doing any inversion. So again, in this case, with SparseDirectUMFPACK, it does a matrix inversion with DL2 full matrix it does no matrix inversion, okay. But again there's nothing here in solve that you need to change. Help results again is nothing you need to change. It creates a .vtk file, which is actually a text file, but that can be read through visualization software. Okay, in 1D there's actually not a lot to see because it's just a straight line, but in 2D and 3D it's really helpful to see what's happening with your temperature plots or your displacement plots as the case may be. All right, so we'll move on from there down to the L2 norm of the error. All right, Now here I'll write it out on the screen what this is. So we have out L2 norm of the error. Again, this is written on your homework assignment, and we talk about L2 norms in the lectures. Right here it's the square root of the integral over the entire domain of your exact solution, minus your finite element solution. Put dV just for generalization of course, in this case it's just across the x component. Alright, so this U is the exact solution. And is your approximate, or finite element solution. Okay, so let's look at how we'll do that. All right, so first I define this double L2 norm is equal to zero and eventually That's the value we'll be returning really the square root. So L2 norm will be that integral and then we square root it as we return it, okay? We have again a constant unsigned int of dofs_per_elem, which is again, just a number of notes per element. Our local_dof_indices vector and I've created these variables u_exact or just which is our approximate solution, our finite element solution. X, which we will use to find the value of X at each point. Again, X is the value in the real domain, the coordinate in the real domain. And HE, the element length. All right, we have the same loop over elements. Let's go back to the board for a little bit. We're going to be integrating this through Gaussian quadrature. The reason why we have this loop over elements is because we're breaking up this integral. First we break it up into loop over elements. And so now instead of performing the integral of sigma over full domain, now we're adding up individual integrals over each element's domain. Still have u minus dV. All right, now, this integral. Remember, we're using Gaussian quadrature. So, inside this element loop, we will now have another loop. Actually, first, let me, let's convert to our bi-unit domain. So we're going from minus one to one. U. Again, now these are being evaluated like c. And to convert, we multiply by he over two. Remember, we had that same he over two factor in our f local from doing that conversion as well, right? And now it's in the d c domain, okay. And now from there it's easy to go to our quadrature. Then I'll keep our square root we still have our loop over at the elements. So that would be element equal to zero less than the total number of elements. Although actually we will be using our iterator again to loop over elements. And now we're going to loop over quadreger points. I'm just going to put a q here but understand that's quadreger points. We'd be going from q equal to zero, less than quadral. Now we will be evaluating u at that quadrature point, and at the quadrature point. And then we will. Oh, I forgot to put my square there. C minus squared from the beginning, right? So that quantity is squared times he over 2. And now we have to remember to multiply by our quadrature weight. And all this is on the inside of the square root still because this is all involved with the integral. So this is the weight for cq, okay? Now again, u is actually a function of x, similar to our forcing function or our body force. It's a function of x and x, itself, is a function of cq. And so you would evaluate c the same way we did with f. Our solution vector D has the values of At the nodes, right. But here we want the values of At the quadrager points, so you will also do similar to finding the value of x, you will interpolate to find the values. So Of CQ is equal to the sum over A, with the same bounds as before. It will be DA, so that's your solution vector, at node A., times NA CQ. And again this D will come from D, we use local d ref indices again to convert from our local node number of A. To the global node number because d, of course, is a global vector. And so we need a global index. All right, and so now with this, you should be able to create that integrand, okay. Let's go back to the code I've actually again I found for you, just as before. I found x for you again. Just the same way as before. No location, again, is how we find xa, or in this case xb times basis function b at the particular quad point. Now remember, when we're doing a summation we always need to zero out x equals zero, equals zero before we start adding to it. Otherwise the numbers will be, if we don't zero out X and Beforehand, then they'll be including previous values of X and And they'll be getting much larger than they actually should be. Okay, so we zero those out before you perform the summation. And Again, here is D, local dof indices of B times our basis function. All right, so now we get to the line that you have to do. And essentially, this is what your doing. Adding it up with an L2 norm okay. And then we gout out of loop and it returns the square root. All right, so if you remember, why do we even do this L2 norm error? It's so that you can verify that your finite ultimate solution is converging to the correct solution as you increase either the basis function order or as you increase the number of elements. Now something to watch out for there's something to think about is what happens when your basis function order is same as the polynomial order of your exact solution. What does that do to your L2 norm? Think about that. Also, what happens as you increase, once you have a really high number of elements in your mesh. And look at what happens the L2 norm. Is it still decreasing? Is it still converging at an optimal rate as you increase element sizes? If not, think about why that might be the case, okay. And think about what relation the computer, the machine error has to do with that, all right? Okay, so that concludes the first coding assignment and our discussion of the template.