help leastsquares1 function [tp,yp] = leastsquares1(N,Np); This function implements the least squares method for the problem y'' + y = -t subject to homogeneous Dirichlet boundary conditions. N denotes the number of basis functions, and Np denotes the number of points in the output arrays for xp and up, for plotting the solution. The basis functions are (1-t)*t^k. [tp,yp] = leastsquares1(1,1000); maxer = 0.0091 plot(tp,yp,'g'); hold on [tp,yp] = leastsquares1(10,1000); maxer = 3.7026e-14 plot(tp,yp,'r'); hold on [tp,yp] = leastsquares1(2,1000); maxer = 0.0017 plot(tp,yp,'b--'); hold on [tp,yp] = leastsquares1(3,1000); maxer = 7.8999e-05 plot(tp,yp,'k--'); hold on figure [tp,yp] = leastsquares1(1,1000); maxer = 0.0091 [tp,yp] = leastsquares2(1,1000); maxer = 0.0104 plot(tp,yp,'r'); hold on [tp,yp] = leastsquares2(100,1000); maxer = 2.4398e-06 plot(tp,yp,'b'); hold on [tp,yp] = leastsquares2(2,1000); maxer = 0.0039 plot(tp,yp,'g--'); hold on [tp,yp] = leastsquares2(3,1000); maxer = 0.0020 plot(tp,yp,'k--'); hold on [tp,yp] = galerkin1(3,1000); maxer = 2.5670e-05 plot(tp,yp); help fem1 function [tp,yp] = fem1(N,Np); This function implements the finite element method with piecewise linear continuous basis functions for the PDE y'' + y = -t subject to homogeneous Dirichlet boundary conditions. N denotes the number of basis functions, and Np denotes the size of the arrays for tp an the function values of the approximation yp for plotting. [tp,yp] = fem1(2,1000); maxer = 0.0125 plot(tp,yp); hold on [tp,yp] = fem1(100,1000); maxer = 1.2228e-05 plot(tp,yp,'r'); [tp,yp] = fem2(3,1000); maxer = 0.0054 plot(tp,yp); hold on [tp,yp] = fem2(1000,1000); maxer = 4.3639e-06 plot(tp,yp,'r'); hold on [tp,yp] = fem2(250,1000); maxer = 2.6607e-04 plot(tp,yp,'g--'); hold on figure [tp,yp] = fem3(25,1000); maxer = 2.8830e-04 plot(tp,yp,'k'); hold on exit