Feeds:
Posts

## SAGE tip: Simplifying a matrix

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, $M$,

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

belongs to the orthogonal group, i.e., $M M^t=1$.

```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.