Monday, June 3, 2019
Inverse Matrix Condition Number
Inverse intercellular substance tally NumberInverse Matrix and Condition No.Saswati Rakshit contents (Jump to)AimScope/ApplicationsIntroduction/BasicsObjectiveSystem give earMathematicsFigure/DescriptionsFuture WorksReferencesAimConsider 2 hit-or-miss matrices B and C of size 88 and write a cpgm / matlab to find A to satisfy the bellow statusIf AB = CProve A = CB-1And repeat the pgm for ground substance of size 3232 and 128128.Scope/ApplicationIn many applications we require inversion of intercellular substance. In Linear Algebra, if AB=C, and from B and C we female genitals compute A where A=CB-1.Stimulus-Response ComputationsIn this framework, a schema is provided with an stimulant drug, called astimulus, and the imparting solvent of the system is measured. Some typical examples of stimuli are visual scenes i.e. if we increase incident lights intensity past scenes brightness allow increase. The general goal is to find afunctionthat unblemishedly describes the relation between stimulus and response.Many systems can be modeled as a linear combination of equations, and thus written as a matrix equationInteractionsresponse= stimuliThe system response can thus be ensnare victimisation the matrix opposite word.Sometimes in escort processing application if we baffle noisy image matrix and if we know what the noise matrix was added we can find the clear image by multiplying noisy image matrix with inverted noise matrix.Intro/BasicsWe get under ones skin considered two 88 matrices B and C. We suppose AB = C. Now by performing matrix propagation on A and B we detect C. Now we have to compute A from B and C.So AB = C and we have to proof A = CB-1.It is conceptually easy to compute AB = C and to find A = CB-1 for 2 dimensional matrices. But for large dimensional matrices it is non possible to easily compute be start out thither is both(prenominal) round off misplays in A which is the final result of B-1 related to Bs discipline repress. Thecon dition make outof a function with respect to an argument measures how much the fruit value of the function can change for a small change in the input argument.The condition consequence of a regular (square) matrix is the product of the norm of the matrix and the norm of its inverse and hence depends on the kind of matrix-norm. Condition number of a square nonsingular (invertible) matrix A is delineate bycond () = where the above could be any of the norms defined for matrices. The numerical value of the condition number of an nn matrix depends on the particular norm apply .The norm of a square matrix A is a non-negative real number denoted by A. These matrix norms have the following properties1. A if A 02. A A for any scalar value A B A BAB ABAx Afor any vector The norm of a matrix is a measure of how large its elements are. It is a way of determining the size of a matrix that is not necessarily related to how many rows or columns the matrix has. Three commonly used norms are1. The 1-norm = This is the maximum absolute column bestow where simply we sum the absolute value down each column and then take the biggest answer.2. The inifinity-norm = This is the maximum absolute row sum where simply we sum the absolute set along each row and then take the biggest answer.3. The Euclidean norm = This is the square root of the sum of all the squares.However, regardless of the norm, this condition number is evermore greater or equal to 1. If it is close to one, the matrix is well conditioned which means its inverse can be computed with good accuracy. If the condition number is large, then the matrix is said to be ill-conditioned. Practically, such a matrix is almost singular (not invertible), and the computation of its inverse or beginning of a linear system of equations is prone to large numerical errors. A matrix that is not invertible has the condition number equal to infinity. Mathematically, if the condition number is less than , the matrix is inverti ble. Numerically, there are roundoff errors which occur. A high condition number means that the matrix is almost non-invertible. The higher the condition number, the greater is the error in the calculation. This condition number helps to estimate how difficult a matrix will be to numerically invert. This condition number has certain properties1. For any matrix A, cond (A) 12. For identity matrix, cond (I) = 13. For any matrix A and scalar , cond A) = cond (A)4. For any diagonal matrix D = Diag(di), cond (D) = (max di)/(mindi)A matrix A is ill-conditioned if relatively small changes in the input (in the matrix A) can cause large change in the railroad siding (the solution of Ax = b), i.e. the solution is not very accurate if input is rounded. otherwise it is well-conditioned. If a matrix is ill-conditioned, then a small roundoff error can have a drastic effect on the output. However, if the matrix is well-conditioned, then the computerized solution is quite accurate. Thus the accur acy of the solution depends on the conditioning number of the matrix.ObjectiveTo know how to determine the matrix inverse in an efficient manner.If AB=C and we have to prove A=CB-1 where A, B and C are nn matrices (n = 8, 32, 128) and find out the condition number of matrix using norms and finding accuracy.System flowSteps performed1. Taking two matrices B and C of order 88.2. Performing Matrix multiplication and result is stored in matrix A (performed using C Code)3. Now calculate B-1 (performed using C Code)4. Now again multiplying C and B-1. We get result matrix which is not accurate.5. We need to calculate norms and condition number of a matrix (B) so we need to find norms of B and B-1.We can calculate norms in different way. Here we have used most popularly used 3 types of norms to calculate condition number of that matrix (B) which we need to get in inverse form.The norms are1-norm = Infinity-norm = iii) Euclidean norm = 6. Now we use norms to find condition number of matr ix B by using formulacond (B) = Flow DiagramyesnoMathFor 22 MatrixFirst we consider a 22 matrix such thatA= B=So by multiplying A and B we ge a 22 matrix C =Now We need to prove A=CB-1So we need to find B-1B-1 = 0.800 -0.200-0.600 0.400So now by doing CxB-1 = =A (proved)Before finding B-1 we can calculate condition number of B for the correctness of above proof,As we know cond (B) = Condition number using the 1-norm and inifinity-normFormula usedRow Sum taking absolute valuesB = 2 133 47 pillar sum 5 5(taking absolute values) (max)Row sumB-1 = 0.800 -0.200 1.000-0.600 0.400 1.000Col Sum 1.4 .6Applying 1-Norm = = maximum absolute column sum = 5, 1 = 1.4,So,cond1 (B) = 1 = 51.4= 7Applying infinity-norm = = max absolute row sum = 7, = 1So,cond (B) = = 7Like this way we have also found condition number using the Euclidean norm which is = =5.47 = 1.095CondE (B) = E = 5.82Here cond(B) is low in all cases.so we successfully get A =C.Because of low condition number of B,the inverse of B is acceptable.For 88 MatrixA = 1 2 3 4 1 2 2 12 3 1 4 3 4 2 14 1 3 2 3 3 1 22 2 1 4 2 2 2 13 2 1 4 3 1 2 11 1 2 3 1 2 2 11 2 1 2 1 2 1 22 2 3 3 2 1 2 2B= 4 1 3 2 3 3 1 22 3 1 4 3 4 2 12 2 1 4 2 2 2 11 1 2 3 1 2 2 12 2 3 3 2 1 2 21 2 3 4 1 2 2 11 2 1 2 1 2 1 23 3 1 3 2 3 1 1C=AB=27 30 28 52 27 37 28 2035 38 42 64 35 46 35 2742 35 41 59 37 43 31 2729 29 32 49 28 37 27 2234 30 35 50 32 39 28 2522 24 24 41 21 29 22 1723 25 22 39 22 30 20 1534 33 30 53 32 40 28 23B-1= -0.016 -0.429 0.063 0.524 0.063 -0.397 -0.222 0.587-0.365 0.143 -0.540 0.048 0.460 -0.127 -0.111 0.5080.095 0.071 -0.381 -0.143 0.119 0.381 -0.167 -0.0240.270 -0.214 0.921 -0.905 -0.579 0.746 0.278 -0.4840.206 0.571 0.175 -0.810 0.175 0.159 -0.111 -0.6350.079 0.143 -0.317 0.381 -0.317 -0.016 0.111 0.063-0.571 0.071 -0.714 1.857 0.786 -1.286 -0.500 0.6430.159 -0.214 0.365 -0.238 -0.135 -0.032 0.722 -0.373A=CB-1 =0.995 1.983 3.029 3.987 1.029 1.984 2.006 0.9791.992 2.975 1.035 3.983 3.035 3.980 2.005 0.9723.989 0.971 3.029 1.984 3.029 2.981 1.006 1.9701.993 1.980 1.027 3.987 2.027 1.984 2.004 0.9772.991 1.976 1.027 3.986 3.027 0.983 2.004 0.9740.996 0.986 2.022 2.990 1.022 1.987 2.004 0.9830.994 1.986 1.021 1.991 1.021 1.988 1.005 1.9821.992 1.979 3.028 2.987 2.028 0.983 2.007 1.975Relative Error for A11=(1-.995)=.005,A12= 0.017 and so onWhen we perform C B-1, we do not get original value of A because of B-1. If B-1 is not accurate we will not get accurate A. To get accuracy of A-1 we need to find condition number of B.As we know cond (B) = Condition number using the 1-norm and inifinity-normFormula usedRow Sum taking absolute valuesB = 4 1 3 2 3 3 1 2 192 3 1 4 3 4 2 1 20 (max)2 2 1 4 2 2 2 1 161 1 2 3 1 2 2 1 132 2 3 3 2 1 2 2 181 2 3 4 1 2 2 1 161 2 1 2 1 2 1 2 123 3 1 3 2 3 1 1 17Column sum 16 16 15 25 16 19 13 11(taking absolute values) (max)B-1 =For B-1, Row sum (max) taking absolute values = 6.428 (7th row)and column sum(max) taking absolute values = 4.906 (4th column)Applying 1-Norm = = maxim um absolute column sum = 25, 1 = 4.906,So,cond1 (B) = 1 = 254.906 = 122.65Applying infinity-norm = = max absolute row sum = 20, = 6.428So,cond (B) = = 206.428 = 128.56.Like this way we have also found condition number using the Euclidean norm which is = 17.83.So here we can say that as the condition number of matrix B is high for all three cases, therefore the inverse of this matrix is showing numerical roundoff errors.Concept of Relative Error and Condition Number hold A is nonsingular and Ax = b if we change b to b + b, the new solution is x + x withA(x + x) = b + b the change in x is x = A-1bcondition of the solution the equations are well-conditioned if small b results in small x the equations are ill-conditioned if small b can result in large xSingular matrixA square matrix is called singular matrix if its determinant is zero.i.e. a singular matrix is not invertibleExampleConsider the linear system Ax = b withSo =So here we easily find x=Now ,we change a small in b.let chang e in b is b=So changed value=and solving the system A = we get =A=where x= changed to = out-of-pocket to small change in b.Now to calculate least condition number of the system we need to find Relative Error in the output and relative error in the input.Here we haverelative error in the input/relative residual. = 0.01Relative Error in the output =1As we know,If condition number is closed to 1 then relative error and relative residual will be close.The condition number is defined byRelative error in the output =Condition number Relative error in the input.So,condition number= 1/.01=100A matrix has high condition number is related to the fact that A is close to the singularmatrix B=The following result shows that 1/cond(A) indicates how close A is to a singular matrix.Here cond(A) is 100 so, 1/cond(A)=.01 which is close enough.DescriptionThe condition number associated with thelinear equationAx=bgives a bound on how imprecise the solutionxwill be after approximation. This is bef ore the effects ofround-off errorare taken into account conditioning is a property of the matrix.Weshould think of the condition number as being the rate at which the solution,x, will change with respect to a change inb. Thus, if the condition number is large, even a small error inbmay cause a large error inx. On the other hand, if the condition number is small then the error inxwill not be much bigger than the error inb.The condition number may also be infinite, but this implies that the problem does not possess a unique, well-defined solution for each choice of data that is, the matrix is not invertible, and no algorithm can be expected to reliably find a solution.For large dimensional matrix such as for 3232 and 128128, the condition number is high and so inverse of that large dimensional matrix will give much error in output.Codes and OutputMatrix multiplicationint main()int m, n, p, q, c, d, k, sum = 0int A1010, B1010, C1010printf(Enter rows and columns of An)scanf(%d%d, m, n )printf(Enter the elements of An)for (c = 0 c for (d = 0 d scanf(%d, Acd)printf(Enter rows and columns of Bn)scanf(%d%d, p, q)printf(Enter the elements of Bn)for (c = 0 c for (d = 0 d scanf(%d, Bcd)for (c = 0 c for (d = 0 d for (k = 0 k sum = sum + Ack*BkdCcd = sumsum = 0for (c = 0 c for (d = 0 d printf(%dt, Ccd)printf(n)getch()Matrix inverseincludeincludeint main()float a1010,b1010,tem=0, temp=0,temp1=0,temp2=0,temp4=0,temp5=0int n=0,m=0,i=0,j=0,p=0,q=0printf(Enter size of 2d array(Square matrix) )scanf(%d,n)for(i=0ifor(j=0jprintf(Enter element no. %d %d ,i,j)scanf(%f,aij)if(i==j)bij=1elsebij=0for(i=0itemp=aiiif(temptemp=temp*(-1)p=ifor(j=i+1jif(ajitem=aji*(-1)elsetem=ajiif(temptemp=temp*(-1)if(temtemp)p=jtemp=aji//row exchange in both the matrixfor(j=0jtemp1=aijaij=apjapj=temp1temp2=bijbij=bpjbpj=temp2//dividing the row by aiitemp4=aiifor(j=0jaij=(float)aij/temp4bij=(float)bij/temp4// qualification other elements 0 in order to make the matrix a an indentity matrix and obtaining a inverse b matrixfor(q=0qif(q==i)continuetemp5=aqifor(j=0jaqj=aqj-(temp5*aij)bqj=bqj-(temp5*bij)printf(nnn)printf(Inverse of the matrix using Guass jordan elimination methodnn)for(i=0ifor(j=0jprintf(%.3f,bij)printf(n)getch()Matrix Condition Numberinclude includeint main()int i,j,n,p,x=0,m=0,q,z=0,i1,j1float Cond_A,poo,a55,b5,c5,A5050,B5050,k50,l50printf(n n)printf(Program to find condition number of a matrix using infinity-norm)printf(n nn)printf(Enter rows and columns of An)scanf(%d%d, m, n)printf(Enter the elements of An)for (i = 0 i for (j = 0 j scanf(%f, Aij)for(i=0ibx=0cx=0for(j=0jbx=bx+Aij++xfor(i=0i//FINDING LARGESTif(bim)m=biprintf(largest row sum is %d,m)printf(nnEnter rows and columns of invAn)scanf(%d%d, p, q)printf(Enter the elements of An)for (i1 = 0 i1 for (j1 = 0 j1 scanf(%f, Bi1j1)for(i1=0i1kz=0lz=0for(j1=0j1kz=kz+Bi1j1++zpoo = k0for(i1=1i1//FINDING LARGESTif(ki1poo)poo=ki1printf(largest row sum is %f,poo)Cond_A=m*pooprintf(nnCondition number of A is %f,Cond_A)//retu rn 0getch()Future worksIf we work with a foggy image matrix(C) and we know the fog matrix(B) added to that image and the relation AB = C exist we will know whether it is possible to get the clear image matrix(A) by doing CB-1 calculating condition number of matrix B. If the condition number of matrix B is high then it is not possible to get accurate A from CB-1 as roundoff errors will increase.ReferencesMatrix Inverse and Condition, Berlin Chen, Department of Computer Science Information Engineering, National Taiwan Normal University.Inversion error, condition number, and approximate inverses of uncertain matrices,Laurent El Ghaoui, Department of Electrical Engineering and Computer Science,University of California at Berkeley, Berkeley, CA 94720, USA.faculty.nps.edu/rgera/MA3042/2009/ch7.4.pdfwww.rejonesconsulting.com/CS210_lect07.pdfhttp//teal.gmu.edu/ececourses/ece699/notes/note4.htmlWeisstein, Eric W. Matrix Norm. From MathWorldA Wolfram Web Resource. http//mathworld.wolfram.com /MatrixNorm.html
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.