ESc101N Laboratory Assignment Thursday of week of 16/8/04 Write a program (with one class and that too having only the "main" method) to find the eigen values and eigen vectors of a 2X2 matrix. You may assume that the input matrix is non-singular and has integer elements. 1) Use InputBox Class (GetInteger Function) and OutputBox Class of package javabook for taking input from the user and for displaying results. The matrix ishould be read in row major order, i.e., M11, M12,M21,M22. 2) Method : The eigen value equation is M.V = e.V, where V=(V1,V2) is the eigen vector and e is the eigen value. A 2x2 matrix will have up to two eigen values and two eigen vectors. To solve theequation we transform it to (M-eI).V = 0 where I stands for identity matrix. Expanding it we get two equations: M11.V1 - e.V1 + M12.V2 = 0 (1) and M21.V1 + M22.V2 - e.V2 = 0 Simplifying these equations leads to the equation e^2 - e.(M11 + M22) + (M11.M22 - M12.M21) = 0. Here e^2 denotes the square of e. Solving this equation gives tow eigen values, say e1 and e2. Note to compute the square-root, use Math class. It has a class method called "pow(a,b)". It takes double arguements and gives a^b (a power b). Math class is in java.lang which you do not have to import. The class methods can be referred by the class name. So use Math.pow(.,.). Next we will compute the eigen vectors corresponding to e1 and e2 respectively. Since equation (1) is homogeneous, its solution will not be unique. In other words if V = (a,b) is an eigen vector for eigen value e1, then (2a, 2b) is also an eigen vector corresponding to e1. This assume that V1 = 1 and thus V2 = -M12/(M11 - e1). Thus eigen vector for e1 is (1, -M12/(M11 - e1)). Similarly the eigen vector for e2 is (1, -M12/(M11 - e2)). 3) Note that the eigen values and eigen vectors in general will be non-integer. Therefore, use float variables to store them. For matrix elements use int type variables.