Normal and Trace of a Matrix in JavaIn this section, we will learn how to calculate the normal and trace of a matrix in Java. Before moving to, the program, first we will understand the what is normal and trace of a matrix. Normal of a MatrixThe normal of a matrix is the square root of the sum of squares of all the elements of a matrix. For example, consider the following matrix. First, we will calculate the sum of the square of each element. 92 + 82 + 22 + 12 + 42 + 72 + 32 + 52 + 62 81 + 64 + 4 + 1 + 16 + 49 + 9 + 25 + 36 = 285 Now, calculate the square root of the sum of squares. √285 = 16.8819430161 Trace of a MatrixThe trace of a matrix is the sum of all the elements present in the principal diagonal (upper left to lower right). Note that the matrix must be a square matrix (the number of rows and columns must be the same). It is useful to prove results in linear algebra. For example, consider the following matrix. Trace for the above matrix is 5 + 4 + 7 = 16. Java Program to Find Normal and Trace of a MatrixMatrixNormalTrace1.java Output: Similarly, we can also find the normal and trace of a matrix using function. MatrixNormalTrace2.java Output: Next TopicRight View of a Binary Tree in Java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India