Tema11 - Matlab solution to Prob. 11.11 (ii): a=[1 4 9 16;4...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Matlab solution to Prob. 11.11 (ii): a=[1 4 9 16;4 9 16 25;9 16 25 36;16 25 36 49] a = 1 4 9 16 4 9 16 25 9 16 25 36 16 25 36 49 b=[30 54 86 126] b = 30 54 86 126 b=b' b = 30 54 86 126 x=a\b Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.092682e-018. x = 1.1053 0.6842 1.3158 0.8947 x=inv(a)*b Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.092682e-018. x = cond(a) ans = 4.0221e+017 11.12 Program Linsimp Use IMSL Implicit None Integer::ipath,lda,n,ldfac Parameter(ipath=1,lda=3,ldfac=3,n=3) Integer::ipvt(n),i,j Real::A(lda,lda),Rcond,Res(n) Real::Rj(n),B(n),X(n) Data A/1.0,0.5,0.3333333,0.5,0.3333333,0.25,0.3333333,0.25,0.2/ Data B/1.833333,1.083333,0.783333/ Call linsol(n,A,B,X,Rcond) Print *, 'Condition number = ', 1.0E0/Rcond Print * Print *, 'Solution:' Do I = 1,n Print *, X(i) End Do End Program Subroutine linsol(n,A,B,X,Rcond) Implicit none Integer::n, ipvt(3) Real::A(n,n), fac(n,n), Rcond, res(n) Real::B(n), X(n) Call lfcrg(n,A,3,fac,3,ipvt,Rcond) Call lfirg(n,A,3,fac,3,ipvt,B,1,X,res) End 11.13 Option Explicit Sub TestChol() Dim i As Integer, j As Integer Dim n As Integer Dim a(10, 10) As Single n = 3 a(1, 1) = 6: a(1, 2) = 15: a(1, 3) = 55 a(2, 1) = 15: a(2, 2) = 55: a(2, 3) = 225 a(3, 1) = 55: a(3, 2) = 225: a(3, 3) = 979 Call Cholesky(a(), n) 'output results to worksheet Sheets("Sheet1").Select Range("a3").Select For i = 1 To n For j = 1 To n ActiveCell.Value = a(i, j) ActiveCell.Offset(0, 1).Select Next j ActiveCell.Offset(1, -n).Select Next i Range("a3").Select End Sub Sub Cholesky(a, n) Dim i As Integer, j As Integer, k As Integer Dim sum As Single For k = 1 To n...
View Full Document

This note was uploaded on 03/13/2012 for the course AEROSPACE 301 taught by Professor Pfchang during the Spring '12 term at Shandong University.

Page1 / 10

Tema11 - Matlab solution to Prob. 11.11 (ii): a=[1 4 9 16;4...

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

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