# Summing matirx diagonals

Funkybeatzzz shared this question 2 years ago

Hello!

I am currently teaching various methods of expanding and factoring polynomial functions and need a little help. When doing the area model for factoring, I've set up the coefficients of two polynomials as separate matrices and multiplied them together. To get the coefficients of the function of the resulting polynomial you must add the diagonals. I cannot figure out how to do this in GeoGebra so any help would be appreciated. Example below:

• m1 = {{5}, {0}, {9}, {-1}, {7}}
• m2 = {{2, 3, -1}}
• m1*m2 = m3 = {{10, 15, -5}, {0, 0, 0}, {18, 27, -9}, {-2, -3, 1}, {14, 21, -7}}

The coefficients of the resulting polynomial should be:

• l3 = {10, 15, 13, 25, 2, 22, -7}

Thanks!

1

Thank you, but it's not what I'm looking for. I know how to do what you've shown already. I'm look for a way to automate this as calling and adding individual matrix elements could become cumbersome with large matrices. Thanks again!

1

With all coefficients and independent of dimension

1

Improved

- optimize the count of iteration

- with this optimizing: KeepIf() is obsolete