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

7 Answers

+ 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]

+ 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

+ 1

Thanks you for the reply😊. I do this but I don't know what is wrong with it?

0

Sorry sir for this inconvenience. Can you please help to code solution to this mathematical problem? Explanation will also help me.

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.

Hot today

What is indentations... ?

6 Votes

Application RAM usage

1 Votes

Showing errors!

2 Votes

About Java McQ

0 Votes

Q. Anna is 18 years old

-2 Votes

int num = 2;
int x = 3;
if(num >= 2) {
if(x > 4) { num = 3; }
else { num = 4; }
}
else {x = 1; }

1 Votes

Balconies Problem in C

0 Votes

Need solution

0 Votes