Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

linear algebra derivative expressions

asked 5 years ago

Tintin1 gravatar image

updated 5 years ago

How do I differentiate y=Ax symbolically in sagemath with respect to the vector x? The result is obviously A. Similarly, I would like to be able to calculate the derivative of the quadratic form α=xAx. 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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
0

answered 5 years ago

Emmanuel Charpentier gravatar image

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

Preview: (hide)
link
0

answered 5 years ago

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

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 α with respect to x is simply xxtA.

No computation necessary; just a calculus book.

Preview: (hide)
link

Comments

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

Tintin1 gravatar imageTintin1 ( 5 years ago )

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 ( 5 years ago )

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: 5 years ago

Seen: 450 times

Last updated: Nov 04 '19