## SAGE tip: Simplifying a matrix

January 22, 2011 by doxdrum

Hi there!

Today’s tip is very useful, and we should thank Simon King for it.

Suppose we are trying to prove that, the matrix, ,

**sage:** M = matrix([[sin(x), cos(x)],[-cos(x),sin(x)]])

belongs to the orthogonal group, i.e., .

**sage:** E = M*M.transpose()

**sage:** E

[sin(x)^2+cos(x)^2 0]

[0 sin(x)^2+cos(x)^2]

For simplifying the matrix, unfortunately, one should simplify each element, it’s done with the following line,

**sage:** E.apply_map(lambda x: x.simplify_full())

[1 0]

[0 1]

Thanks Simon.

### Like this:

Like Loading...

*Related*

on February 4, 2011 at 9:14 pm |SAGE tip: Convert a 2D list into a matrix « Doxdrum's Blog[…] When I ran the worksheet, the result of the Ricci tensor was right, but didn’t simplify to zero… So, I decide to bypass this applying the trick of matrix simplification. […]

on February 24, 2011 at 11:22 pm |SAGE tip: Exponentiate a Matrix « Doxdrum's Blog[…] way of simplifying the matrix elements of the exponentiation, not even with the procedure post in here. I didn’t try with the rewrite […]