solve linear system of r equations - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: solve linear system of r equations (/thread-24578.html) |
solve linear system of r equations - amalalaoui - Feb-20-2020 Hello I need your help plealse I want to solve this linear systems of r equations defined by this formula in order to find the values of
\beta_{i,j}^{s} for of fixed s `\begin{equation}v_{n}^{(s)}= \sum\limits_{i=1}^{l} \left(\sum\limits_{j=0}^{m_{i}-1} \beta_{i,j}^{(s)} n^{j} \right) \lambda_{i}^{n}, \;\;\; 0 \leq s \leq r-1 \label{sequenceBeta} \end{equation} `where l the number of eigenvalues of the matrix
m_{i} the multiplicity of the eigenvalue
\lambda_{i}
I know that i should use np.linalg.solve(matrice,vecteur) i have tried to solve this system but i found a difficulty in programming it The code is as follow def beta_vanderm(l,s,n): len_matrix=len(l) beta=np.zeros(len_matrix) mat=np.zeros((len_matrix,len_matrix)) vect=np.zeros(len_matrix) evals, evecs = la.eig(l) unique_elements, counts_elements = np.unique(evals, return_counts=True) print unique_elements print counts_elements for f in range(0,len_matrix): vect[f]=delta(s,f) print vect[f] for k in range(0,len_matrix): for u in range(0,len_matrix): additionner=0 for i in range(1,len(unique_elements)+1): additionner=0 for j in range(0,counts_elements[i-1]): additionner+=(n**j)*(unique_elements[i-1]**n) mat[k][u]=additionner beta=np.linalg.solve(mat,vect) return beta |