Inner product calculation using discretised Chebyshev points and a energy matrix
3 views (last 30 days)
Show older comments
I am trying to generate a matrix A which looks at the first K eigenvalues/eigenvectors in a eigenvalue problem.
The solution vector is q = [u,v,w,rho,T]. (Think 'fluid dynamics'.)
A is defined as the inner product of the k^th eigenvector with the the l^th eigenvector.
Matrix M is an energy 'weight' matrix specific to my problem. My problem is discretised using Chebyshev gridpoints, therefore i have included an integral 'weight' to each of the values in M as per the Chebyshev integral weightings.
Here is a brief look at the maths that I'm trying to implement.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1671331/image.png)
where, ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1671336/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1671336/image.png)
Here's my code (using arbitrary rho, Tt, w and qtildeu) - is this implementation of the integral in for the A matrix elements defined in the photo above correct in my code?
Mach = 0.01;
gamma = 1.4;
K = 12; % number of eigenvectors that are included
N = 100; % number of gridpoints
Z = zeros(N);
rho = ones(N,1); % arbitrary rho
Tt = rho.*1.234; % arbitrary Tt
w = ones(N,1); % chebyshev weights set as one for sake of MATLAB online question
Q1 = diag(rho.*w);
Q2 = diag(rho.*w);
Q3 = diag(rho.*w);
Q4 = diag(Tt./(rho.*gamma.*Mach.^2).*w);
Q5 = diag(rho./(gamma.*(gamma-1).*Tt.*Mach^2).*w);
Q = [Q1 Z Z Z Z;
Z Q2 Z Z Z;
Z Z Q3 Z Z;
Z Z Z Q4 Z;
Z Z Z Z Q5]; % MATRIX M from question
qtildeu = 0.5.*ones(5*N,K); % random eigenvectors
% obtaining weight matrix A
for k = 1:K
for l = k:K
A(k,l) = qtildeu(:,k)'*Q*qtildeu(:,l);
A(l,k) = A(k,l); % symmetric matrix
end
end
1 Comment
Answers (1)
Gautam
on 20 May 2024
Hello, Isabelle
I understand that you want to generate the matrix “A”, which is obtained by
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1698981/image.png)
The attached piece of code implements the matrix product “
” but doesn’t compute the integral. It is also unclear as to what the variable “y” is with respect to which the integral is being performed
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1698986/image.png)
If it is known how the eigen vectors “
” and “
”, and the weight matrix “M” are represented in terms of “y”, one way to compute the integral would be to define the vectors and matrix “
”, “
” and “M” as symbolic arrays and matrix in “y”, compute the product as
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1698991/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1698996/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1699001/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1699006/image.png)
f(y) = ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1699011/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1699011/image.png)
and integrate with respect to “y” under the specified limits using the “int” function to obtain the elements of the matrix A
A(k,l) = int(f, y, 0, inf);
You can refer to the following MathWorks documentation for more information on the “int” function
Int function: https://www.mathworks.com/help/symbolic/sym.int.html
0 Comments
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!