2.2:2.3computerhomework.docx

2.2:2.3computerhomework.docx - n=100...

This preview shows 1 out of 3 pages.

  n = 100; b(2:99) = 40; b([1,100]) = -20; b = b';  a(1:98) = 1; a(99) = -1; a = a'; d(2:99) = -4; d([1,100]) = 4; d = d'; c(1) = -1; c(2:99)=1; c = c'; y = Tri(n,a,d,c,b)';   for  i = 1:1:length(y)     fprintf( 'x(%3.0f ) = %15.10f\n' ,i,y(i)); end   function  x = Tri(n,a,d,c,b) for  i = 2:n     xmult = a(i-1)/d(i-1);     d(i) = d(i) - xmult*c(i-1);     b(i) = b(i) - xmult*b(i-1); end x(n) = b(n)/d(n); for  i = n-1:1     x(i) = (b(i)-(c(i)*x(i+1)))/d(i); end end Output: >> untitled3 x(  1 ) =    -9.28203 x(  2 ) =    -17.1281 x(  3 ) =    -19.2394 x(  4 ) =    -19.7938 x(  5 ) =    -19.9447 x(  6 ) =    -19.9851 x(  7 ) =    -19.9960 x(  8 ) =    -19.9989 x(  9 ) =    -19.9997 x( 10 ) =    -19.9999 x( 11 ) =    -19.9999 x( 12 ) =    -19.9999 x( 13 ) =    -19.9999 x( 14 ) =    -19.9999 x( 15 ) =    -19.9999 x( 16 ) =    -19.9999 x( 17 ) =    -19.9999 x( 18 ) =    -19.9999 x( 19 ) =    -19.9999
Image of page 1

Subscribe to view the full document.

x( 20 ) =    -19.9999 x( 21 ) =    -20.0000 x( 22 ) =    -20.0000
Image of page 2
Image of page 3
You've reached the end of this preview.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern