Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Numerically evaluate the gradient of a function summed over the eigenvalues of a matrix, with respect to matrix parameters
ResourceFunction["NEigenvalueSumGradient"][f, m][x, y, …] finds the gradient of the function f summed over the eigenvalues of the matrix m[x,y,…]. |
Define a symmetric matrix function:
In[1]:= | ![]() |
Find the gradient of the eigenvalue function #Log[#]& summed over the eigenvalues at x=1, y=1:
In[2]:= | ![]() |
Out[2]= | ![]() |
Check:
In[3]:= | ![]() |
Out[4]= | ![]() |
A non-symmetric matrix:
In[5]:= | ![]() |
Out[7]= | ![]() |
Find the gradient of the function Sin[#]Log[#]& summed over the eigenvalues at x=1, y=1:
In[8]:= | ![]() |
Out[8]= | ![]() |
Check:
In[9]:= | ![]() |
Out[10]= | ![]() |
A somewhat large matrix with two parameters:
In[11]:= | ![]() |
Finding the eigenvalues of even a moderately large matrix with symbolic parameters is slow:
In[12]:= | ![]() |
Out[12]= | ![]() |
Using NEigenvalueSumGradient is quick:
In[13]:= | ![]() |
Out[14]= | ![]() |
Check:
In[15]:= | ![]() |
Out[15]= | ![]() |
Very large matrix:
In[16]:= | ![]() |
Using NEigenvalueSumGradient is reasonably quick:
In[17]:= | ![]() |
Out[17]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License