Jump to content

Wikipedia:Reference desk/Archives/Mathematics/2023 May 16

From Wikipedia, the free encyclopedia
Mathematics desk
< May 15 << Apr | May | Jun >> May 17 >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 16

[edit]

Adding matrices with different dimensions

[edit]

Why is it necessary to leave adding matrices with different dimensions undefined?? Georgia guy (talk) 16:40, 16 May 2023 (UTC)[reply]

Have you found some use for the idea? If you have a use for the idea then you must have some meaning to assign to the business, I'd be interested in what that could be! NadVolum (talk) 16:46, 16 May 2023 (UTC)[reply]
Matrix mathematics is only sensible if you have the same dimensions between the matrices. For example, if you're adding:
To what are you adding the 4 and 2 on the bottom row? --Jayron32 16:52, 16 May 2023 (UTC)[reply]
Some matrix math packages use "broadcasting" to define operations on inputs that have different dimensions. For example, in NumPy: [1]. This is just a convenience that makes sense in some contexts, and to make use of it, you have to know the broadcasting rules used by a particular tool. --Amble (talk) 17:32, 16 May 2023 (UTC)[reply]
I mean, one could define what it means to add matrices with different numbers of dimensions in any number of ways. That's one way to do it. Anyone could do anything. However, under the 'normally understood' method of matrix addition, one adds the numbers termwise to create a new matrix of the same size with the summed totals in the same locations. When the matrices are different sizes, it raises all kinds of issues with how to perform said operation, not the least of which is "to what do we add the numbers in the larger matrix". Workarounds such as the NumPy one are possible, but they are not part of the standard algorithms. --Jayron32 17:56, 16 May 2023 (UTC)[reply]
NumPy is not some obscure footnote along the lines of "anyone could do anything." Like I said, it makes sense in some contexts, and you have to know the rules that are being applied. --Amble (talk) 18:22, 16 May 2023 (UTC)[reply]
Oh, no, I wasn't trying to imply that NumPy was obscure. The point was that NumPy has built in some functionality to deal with asymmetric matrix addition, that functionality should not be meant to imply that, under the standard algorithms of matrices, that matrix addition is normally possibly between non-matching matrices. Someone obviously has a use for such a functionality (which is why it was built in to NumPy). The standard method of matrix addition, however, is not one of those uses. --Jayron32 18:34, 16 May 2023 (UTC)[reply]
I feel that one of the problems that arises is that some of the common-sense expectations and definitions you would have when it comes to matrices and linear maps have to sort of "break" if you define matrix addition for matrices of different sizes. For example, for two matrices A and B and a vector v, you would normally expect (A + B)v = Av + Bv, but when A and B are of different sizes:
1. If the number of columns differ then you have to define matrix multiplication on incompatible sizes (which is its own can of worms), and...
2. If the number of rows differ then you have to define vector addition on incompatible dimensions.
Of course, you could come up with ways of doing these, but as others have mentioned, there are lots of different possibilities, each with their own ups and downs. GalacticShoe (talk) 17:18, 17 May 2023 (UTC)[reply]
It's also important to remember that a matrix is not a mathematical object unto itself, it's a notational system; the rules of working with matrices are largely defined by what you're using them to represent rather than any inherent property of the matrix itself. Most of the rules of matrix mathematics are confined by the rules of linear algebra, where matrices find their most common uses, but if you're using a matrix for another purpose, you can fit it to the rules of that purpose. --Jayron32 18:09, 17 May 2023 (UTC)[reply]