0

Please, help me to write a program which can transform a square matrix to a diagonal matrix if it is possible 🙏

For this, you need to : -take input matrix from user, -echelon that matrix, -multiplie elements of diogonal to obtain an equation of n degree, -then solve that equation to find proper values, -after proper value, find proper vectors Write the D=P-1AP result

23rd Nov 2022, 7:02 AM
Hermione Harry
Hermione Harry - avatar
7 Answers
23rd Nov 2022, 7:50 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Well the task is complex, and on top of that it's loaded with linear algebra that I am not so comfortable with. But let's begin with the first part. Usually we can store a matrix in a two-dimensional array. So when you need to take the data from input, you might first ask the user to enter the number of rows, and the number of columns. Then take all values one by one, in a loop, or you may also take a single line with multiple values and use a split function to process the values. So there are many ways to do this, and you did not give specific information. Ultimately you would end up with a data structure such as this: [ [1, 2, 3], [4, 5, 6] ] and if your language uses 0-based indexing then the value 6, which is the third value in the second row, would be referred to as matrix[1][2]
23rd Nov 2022, 8:27 AM
Tibor Santa
Tibor Santa - avatar
+ 1
You mentioned 4 different languages in tags. Which one are you actually using? Post your code attempt and explain what gives you difficulty in solving this
23rd Nov 2022, 8:01 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Thanks you for the reply😊. I do this but I don't know what is wrong with it?
23rd Nov 2022, 3:45 PM
Hermione Harry
Hermione Harry - avatar
0
Sorry sir for this inconvenience. Can you please help to code solution to this mathematical problem? Explanation will also help me.
23rd Nov 2022, 8:03 AM
Hermione Harry
Hermione Harry - avatar
0
Onto the next step, I would assume that you need to perform Gaussian elimination on the matrix. So based on my research this article would help understanding the requirement https://en.m.wikipedia.org/wiki/Row_echelon_form What we normally do in programming is we write a function which takes the matrix as an input, and provides the echelon form as return value. This is about structuring your code, breaking up the task into parts that can be individually tested. How the function works should be designed by you, and it requires you to know the mathematical background, so that you can describe the steps what should be done. Write up an example what is the starting state, what steps to perform and how the output looks like. If this is clear then you can start writing code.
23rd Nov 2022, 8:32 AM
Tibor Santa
Tibor Santa - avatar
23rd Nov 2022, 3:55 PM
Hermione Harry
Hermione Harry - avatar