2.Write down the matrix equation to solve in order to find the finite difference approxima-tion withN= 4for the same diff
Get answer to your question and much more
3.Use MATLAB/Octave to solve the matrix equations you derived in the last two prob-lems for the vector F that approximates the solution (i.e., withN= 4).Then redo thecalculation withN= 50and plot the resulting functions.For defineNandΔxN=4;DX=2/N;Define the matrixLwhereLFcorresponds tof(x)L=diag(-2*ones(1,N+1))+diag(ones(1,N),1)+diag(ones(1,N),-1);L(1,1)=1;L(1,2)=0;L(N+1,N)=0;L(N+1,N+1)=1;Define the matrixQwhereQFcorresponds toxf(x)X=linspace(1,3,N+1);Q=DX^2*diag(X);Q(1,1)=0;Q(N+1,N+1)=0;Define the right side of the equation for the boundary conditions of the first problem.
Get answer to your question and much more