



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
homework codes for all solutions
Typology: Exercises
1 / 6
This page cannot be seen from the preview
Don't miss anything!




b=[3 -9 -5]'; Ab=[A b]; n=length(A); i=2;k=1;Ab(i,:)=Ab(i,:)-(Ab(i,k)/Ab(k,k))Ab(k,:); i=3;k=1;Ab(i,:)=Ab(i,:)-(Ab(i,k)/Ab(k,k))Ab(k,:); i=3;k=2;Ab(i,:)=Ab(i,:)-(Ab(i,k)/Ab(k,k))*Ab(k,:); U=Ab(:,1:3); c=Ab(:,4); x=U\c A\b %swap rows using A=[1 3 4; 2 4 5]; A([1 2],:)=A([2 1],:)
b=[-3 65 -42]'; n=length(A); L=eye(n); U=A; i=2;k=1; L(i,k)=A(i,k)/A(k,k);U(i,:)=U(i,:)-L(i,k)U(k,:); i=3;k=1; L(i,k)=A(i,k)/A(k,k);U(i,:)=U(i,:)-L(i,k)U(k,:); i=3;k=2; L(i,k)=A(i,k)/A(k,k);U(i,:)=U(i,:)-L(i,k)*U(k,:); y=L\b; x=U\y A\b
b=[1 3/2 3]'; L=[whatever you solved by hand]; y=L\b; x=L'\y %IN COMMAND WINDOW syms L11 L21 L31 L22 L32 L33 real L=[L11 0 0;L21 L22 0;L31 L32 L33] L = [ L11, 0, 0] [ L21, L22, 0] [ L31, L32, L33] LL' ans = [ L11^2, L11L21, L11L31] [ L11L21, L21^2 + L22^2, L21L31 + L22L32]
x=0;y(1)=0;y(2)=1;h=0.25; f=@(x,y) [y(2) -0.1y(2)-x]; xf=2; i=1; while x<=xf ysol(i,:)=y; xsol(i,:)=x; k1=hf(x,y); k2=hf(x+(h/2),y+(k1/2)); k3=hf(x+(h/2),y+(k2/2)); k4=hf(x+h,y+k3); y=y+(1/6)(k1+2k2+2k3+k4); x=x+h; i=i+1; end [xsol ysol] plot(xsol,ysol)
x=linspace(0,pi/2,n); h=x(2)-x(1); A=zeros(n); b=zeros(n,1); for i=2:n- A(i,i)=4h^2-2; A(i,i-1)=1; A(i,i+1)=1; b(i)=4h^2*x(i); end A(1,1)=1; b(1)=0; A(n,n)=1; b(n)=0; y=A\b plot(x,y)
x=linspace(0,pi/2,n); h=x(2)-x(1); A=zeros(n);