i)=x0(i+1);xO(i+1)=t;endendend%对乂0进行由小到大排序%判断待求值x属于哪个区间form=l:nifxO(m)<=x&x<=xO(m+1)m=m;breakendend%判断待求值X属于哪个区间%求每个区间的长度fort=l:n-1h(t)=x0(t+1)-xO(t);end%求每个区间的长度%^niuAlamda,db=ones(1,n)*2;niu(1)=1;lamda(1)=1;forj=2:n-lniu(j)=h(j-l)/(h(j-l)+h(j));lamda(j)=h(j)/(h(j-1)+h(j));endd(l)=6/h(l)*((y0(2)-y0(l))/h(l)-y0(l));d(n)=6/h(n-1)*(yO(n)-(yO(n)-yO(n-l))/h(n-l));fori=2:n-1d(i)=6*((yO(i+l)-yO(i))/h(i)-(yO(i)-yO(i-1))/h(i-l))/h(i-l)+h(i);end%^niu,lamda,d%消元fork=l:n-1niu(k)=-b(k)*(niu(k)/b(k))+niu(k);b(k+l)=-lamda(k)*(niu(k)/b(k))+b(k+1);d(k+l)=-d(k)*niu(k)/b(k)+d(k);end%消元%回代M(n)=d(n)/b(n)fora=n-l:-1:1M(a)=(d(a)-lamda(a)*M(a+l))/b(a);end%回代x-%求5(X)s=M(m)*(xO(m+1)-x)A3/6*h(m)+M(m+1)*|xO(m))A3/6*h(m)...+(yO(m)-M(m)*h(m)A2/6)*(xO(m+1)-x)/h(m)+(yO(m+1)-M(m+1)•••*h(m)A2/6)*(x-xO(m)/h(j))%求3(X)三、实例求解