Ask Your Question
1

linear algebra derivative expressions

asked 2019-11-03 13:46:47 +0100

Tintin1 gravatar image

updated 2019-11-03 13:49:01 +0100

How do I differentiate $\mathbf{y}=\mathbf{A}\mathbf{x}$ symbolically in sagemath with respect to the vector $\mathbf{x}$? The result is obviously $\mathbf{A}$. Similarly, I would like to be able to calculate the derivative of the quadratic form $\alpha=\mathbf{x}'\mathbf{A}\mathbf{x}$. I would need these calculations in a more complex setting.

I started off with sympy as follows

from sympy import *
n=7 
A = MatrixSymbol('A', n, n)
x = MatrixSymbol('x', n, 1)

Or is there a different library from sympy available for such a problem?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-11-03 23:08:58 +0100

Emmanuel Charpentier gravatar image

I'm out of my depth here, but I'd suggest a look at the Manifolds project, implemented in Sagemath.

edit flag offensive delete link more
0

answered 2019-11-04 06:56:34 +0100

nbruin gravatar image

I assume your matrix A has entries that do not depend on the entries of x? Then with $y=Ax$ you already define $y$ to be a linear function in $x$, so the derivative of $y$ with respect to $x$ is simply $x\mapsto A$.

Similarly, assuming that $A$ a symmetric matrix that is independent of $x$ (otherwise your function doesn't deserve the name quadratic form) you have that the total derivative of $\alpha$ with respect to $x$ is simply $x\mapsto x^t A$.

No computation necessary; just a calculus book.

edit flag offensive delete link more

Comments

You are right, but I am trying to create a procedure for much more complicated algebraic expressions.

Tintin1 gravatar imageTintin1 ( 2019-11-05 13:33:55 +0100 )edit

I suspect you have to write things out in explicit variables then. It looks like you basically want to work with a fairly general vector field. I'm not so sure a computer algebra system can help you much with that without you doing some pretty specific preprocessing. The examples you gave are (trivially) resolved. Perhaps a different example closer to what you want to accomplish would help.

nbruin gravatar imagenbruin ( 2019-11-05 17:31:37 +0100 )edit

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: 2019-11-03 13:46:47 +0100

Seen: 426 times

Last updated: Nov 04 '19