hw3sol

Hw3sol - %Let's define the right hand side vector b b=-5*c01 0-160 0 0[L,U]=lu(A z = L\b c = U\z%part 2 of the problem c01=1:20 for i=c01

Info iconThis preview shows pages 1–18. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem 1 Matlab Code %Let's define a square matrix A=[10 2 -1; -3 -6 2; 1 1 5] %Determinant of A detA = det(A) %Inverse of A invA = inv(A) %Let's see if invA is really the inverse of A I1 = A*inv(A) I2 = inv(A)*A Output A = 10 2 -1 -3 -6 2 1 1 5 detA = -289 invA = 0.1107 0.0381 0.0069 -0.0588 -0.1765 0.0588 -0.0104 0.0277 0.1869 I1 = 1.0000 0.0000 0 0.0000 1.0000 0.0000 -0.0000 0.0000 1.0000
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
I2 = 1.0000 0.0000 0.0000 -0.0000 1.0000 0.0000 0 0 1.0000
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Problem 2 Matlab Code: A = [-cos(pi/6) 0 cos(pi/3) 0 0 0; -sin(pi/6) 0 -sin(pi/3) 0 0 0; cos(pi/6) 1 0 1 0 0; sin(pi/6) 0 0 0 1 0; 0 -1 -cos(pi/3) 0 0 0; 0 0 sin(pi/3) 0 0 1]; b = [0; 1000; 0; 0; 0; 0]; forces = A\b Output forces = -500.0000 433.0127 -866.0254 0 250.0000 750.0000
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
%Let's define the coefficient matrix A A=[-6 0 1 0 0; 3 -3 0 0 0; 0 1 -9 0 0; 0 1 8 -11 2; 3 1 0 0 -4]; c01=10;
Background image of page 10
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 14
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 16
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 18
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %Let's define the right hand side vector b b=[-5*c01; 0; -160; 0; 0]; [L,U]=lu(A); z = L\b; c = U\z %part 2 of the problem c01=1:20; for i=c01 b=[-5*c01(i); 0; -160; 0; 0]; z = L\b; c = U\z; c2(i) = c(2); end plot(c01,c2);grid on 2 4 6 8 10 12 14 16 18 20 2 4 6 8 10 12 14 16 18 20 %problem 5 - Newton's method clear all ; ITERMAX = 2; Tol = 1e-4; % give the initial guess x = [0.75;0.75]; %note I use x(1)=x & x(2) = y iter = 0; while (1) xold = x; %define the Jacobian matrix & right hand side A = [1-x(2) -x(1);x(2) -1+x(1)]; b = -[(x(1)-x(1)*x(2)); (-x(2) +x(1)*x(2))]; %solve the system delx = A\b; iter = iter + 1; disp([ 'Iter : ' num2str(iter)]); %new root x = xold + delx %RE re = abs((x - xold)./x); if ((max(re) < Tol) | (iter == ITERMAX)) break ; end end OUPUT: Iter : 1 x = 1.1250 1.1250 Iter : 2 x = 1.0125 1.0125...
View Full Document

This homework help was uploaded on 04/07/2008 for the course ME 17 taught by Professor Milstein during the Spring '07 term at UCSB.

Page1 / 18

Hw3sol - %Let's define the right hand side vector b b=-5*c01 0-160 0 0[L,U]=lu(A z = L\b c = U\z%part 2 of the problem c01=1:20 for i=c01

This preview shows document pages 1 - 18. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online