Processing math: 14%

First time here? Check out the FAQ!

Ask Your Question
1

Symbolic diagonalization, matrix differentiation and the wedge product

asked 8 years ago

MathCat gravatar image

May I ask whether symbolic entry-wise differentiation of matrices can be done using SageMath? I would like to conduct the following operations:

1.Diagonalize a complicated symbolic matrix.

2.Entry-wise differentiation.

3.The wedge product. I need to be able to take the n-th power of a matrix of 1-forms.

4.Integration (I will take the trace first before integrations so integrations will not be done on matrices. The result is likely to be completely crazy but I assume this can be done)

Please let me know whether this is possible. Thank you very much!

Preview: (hide)

Comments

yes, in pple all this can be done in Sage! of course in practice it'll depend on the complexity of your problem :) for entrywise differentiation, see my answer below for some hints. for point 3, it could be relevant to check this question. and let me add that you may get better answers in this site if you include some code with attempts / a concrete example.

mforets gravatar imagemforets ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
3

answered 8 years ago

mforets gravatar image

updated 8 years ago

The apply_map method is a handy command for entrywise operations. For instance, let

A = matrix([[sin(x), cos(x)],[cos(x), -sin(x)]]);  # define a matrix function of x
A

(sin(x)cos(x)cos(x)sin(x)).

Let's compute the entrywise derivative with apply_map:

A.apply_map(lambda a : a.derivative(x))

\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} \cos\left(x\right) & -\sin\left(x\right) \\ -\sin\left(x\right) & -\cos\left(x\right) \end{array}\right),

and the Jordan canonical form

A.jordan_form()

\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{r|r} -\sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} & 0 \\ \hline 0 & \sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} \end{array}\right).

Another small example, this time with symbolic functions:

var('x y')
m=2; n=4

# create a mxn matrix of symbolic functions in x and y
F = matrix([[function('f'+str(i)+str(j))(x, y) for j in [1..n]] for i in [1..m]]); 
F

\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} f_{11}\left(x, y\right) & f_{12}\left(x, y\right) & f_{13}\left(x, y\right) & f_{14}\left(x, y\right) \\ f_{21}\left(x, y\right) & f_{22}\left(x, y\right) & f_{23}\left(x, y\right) & f_{24}\left(x, y\right) \end{array}\right).

Now, let's ask for the entrywise integral with respect to y of the 2nd derivative with respect to x:

F.apply_map(lambda f : (f.derivative(x, 2)).integrate(y))

\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} \int \frac{\partial^{2}}{(\partial x)^{2}}f_{11}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{12}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{13}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{14}\left(x, y\right)\,{d y} \\ \int \frac{\partial^{2}}{(\partial x)^{2}}f_{21}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{22}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{23}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{24}\left(x, y\right)\,{d y} \end{array}\right).

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 8 years ago

Seen: 1,732 times

Last updated: Feb 12 '17