New answers tagged

2

If your matrix $A$ is close to the identity I guess that you could try the following approximation \begin{align} \log(\det(I + \epsilon B)) &= \log\det(I + \epsilon_0 B) + (\epsilon - \epsilon_0)\operatorname{tr}(B (I + \epsilon_0 B)^{-1}) - (\epsilon - \epsilon_0)^2 \operatorname{tr}(B (I + \epsilon_0 B)^{-1} B (I + \epsilon_0 B)^{-1}) + O(\epsilon^3) \...


8

The LU decomposition will give you what you want with only $\tfrac{2}{3}n^3 + \mathcal{O}(n^2)$ FLOPs. The linear system is solved by solving two triangular systems. The determinant is the product of the determinants of L and U, which, in turn, are the products of the diagonal elements. I should also add that we can't really say anything about the ...


4

In general, I think that the answer to your question about computing a single component is negative (unless you allow for Strassen-like methods, which technically are a positive answer since they have lower complexity than LU/Gaussian elimination). The best way to compute determinants in practice is via Gaussian elimination, so that saves you nothing. (Also, ...


1

Assuming $B$ is not angle-dependent, you know the coefficients of each $f_i$ a priori, and $\mathbf{f}$ can only be evaluated by summing up the spherical harmonics expansion, simplify your problem by making use of the orthogonality of spherical harmonics instead of numerically integrating. Let $f_i(\theta,\phi)=\sum_{lm}f_{i,lm}Y_l^m(\theta,\phi)$. Then your ...


2

Since the $f_i(\theta,\phi)$ are linear combinations of spherical harmonics, we can write $$ \mathbf{f} = F \mathbf{Y} $$ where $\mathbf{Y}$ is a vector of the orthonormalized spherical harmonics - i.e.: $$ \int d\Omega Y_l^m Y_{l'}^{m'*} = \delta_{ll'} \delta_{mm'} $$ So the integral becomes, $$ \int d\Omega \mathbf{f}^{\dagger} (B^{\dagger} + B) \mathbf{f} ...


2

output[i*n + j][k*n + l] = com[k][l] That's your mistake I think -- reversed indices. To compute the matrix $M$ associated to a linear operator $f$ (the way it's usually taught in a linear algebra course), you need to take a basis of the input space $e_1, \dots, e_n$, compute $f(e_J)$ for each $J$, and write its coordinates (wrt a basis of the output space) ...


4

Instead of using 4 levels of nested loops, you can take advantage of Kronecker products to simply your commutator_matrix function to def commutator_matrix(X): id = np.identity(np.shape(X)[0]) return np.kron(np.transpose(X), id) - np.kron(id, X) This is still the transpose of what you want. The function you are looking for is def ...


6

Let's express the matrix $A \in \mathbb{R}^{n \times n}$ with which we want to solve linear systems as $$ A = S + U V $$ where $S$ is a symmetric matrix, $U \in \mathbb{R}^{n \times r}$, and $V \in \mathbb{R}^{r \times n}$. That is, $U V$ is a low rank update to account for the lack of symmetry. From your question, it appears $r$ is just 1 or 2. The ...


Top 50 recent answers are included