I am going to solve an equation containing an exponential matrix $e^{tA} x =b$, which can be obtained naturally through $x=e^{-tA} b$. A is a 1million $\times$ 1 million matrix with stores 7.15 million elements. However, accurately computing a matrix exponential $e^{-tA}$ requires very high computer memory. Although there are methods to quickly solve exponential matrices, such as the Krylov method, they still require high computational costs.
I tried to solve it using the following approximation method: $$ e^{tA} \approx (I + tA + t^2 \frac{A^2}{2!} + t^3 \frac{A^3}{3!}) $$
However, when I try to solve $$(I + tA + t^2 \frac{A^2}{2!} + t^3 \frac{A^3}{3!})x = b$$, the program quickly occupied me Computer memory (64G) and shut down.
A is a positive semidefinite matrix. It seems that diagonalization technology can be used? For example, let $A = P^{-1} L P$, where $L$ is a diagonal matrix. Then the above formula can be transformed into: $$ (I + tA + t^2\frac{A^2}{2!} + t^3\frac{A^3}{3!}) x = b \to (I + t L + t^2\frac{L^2}{2!} + t^3\frac{L^3}{3!}) y = PbP^{-1}, x = P^{-1}yP. $$ Would such diagonalization be costly? Is there any existing library in python that can quickly perform the above operations?
The code I used when solving was pypardiso.spsolve(A,b)
, where A is the left-hand matrix of the above equation. I would like to ask if there is a fast algorithm to solve such an equation?
EDIT I'm trying to solve a parabolic problem $$u_t = \Delta u + f,$$ Subject to the homogeneous Neumann boundary conditions, first of all, in terms of spatial discretization, the mass-lumped finite element method is adopted, and the following discrete equation is obtained: $$ ((u_h)_t ,v_h) = (\nabla u_h, \nabla v_h) + (f,u_h), \quad \forall v_h \in V_h $$ where $V_h$ is the finite element subspace of $H^{1}(\Omega)$. Due to the mass-concentrated finite element method used, the above format can be written in matrix-vector form $$ \boldsymbol{u}_t = L \boldsymbol{u} + \boldsymbol{f} $$ Where $L = -M^{-1} A$, $A = \int_{\Omega} \psi_i \psi_j dx$. $\boldsymbol{u}$ is the vector constructed by the nodal value. The numerical solution satisfies $$ \boldsymbol{u}(t_{n+1}) = e^{\tau L} \boldsymbol{u}(t_n) + \tau \int_{0}^{\tau} e^{-(\tau-s) L} \boldsymbol{f}(t_n+s) ds. $$ I want to discretize in the time direction using explicit Runge-Kutta, getting $$ \boldsymbol{u}_{ni} = e^{-c_i \tau L} \boldsymbol{u}^n + \tau \sum\limits_{j=0}^{i-1} a_{i,j} e^{-(c_i-c_j)\tau L} \boldsymbol{f}_{n,j} $$ $$ \boldsymbol{u}^{n+1} = e^{- \tau L} \boldsymbol{u}^n + \tau \sum\limits_{j=0}^{i-1} b_j e^{- (1-c_j)\tau L} \boldsymbol{f}_{n,j} $$ Where $a_{i,j}, b_i, c_i$ are defined in Runge-Kutta's Butcher table. However, usually calculating the exponential matrix in the above process will cost a very high computational cost. Therefore, I want to approximate the matrix exponential, and finally The following equation is obtained $$ \phi_i(-\tau L) \boldsymbol{u}_{ni} = \left( \boldsymbol{u}^n + \tau \sum\limits_{j=0}^{i -1} a_{i,j}\phi_j(-\tau L) \boldsymbol{f}_{n,j} \right), $$ Where $\phi_i(x)$ is a polynomial function used to approximate $e^{c_i x}$.
Taking this step eliminates the need to calculate the exponential matrix, but introduces an additional solving process. Even so, this method remains faster than computing the exponential matrix, as observed in 1D and 2D examples. However, as the problem transitions to three dimensions, the process becomes less satisfactory. When dealing with a $100^3$ grid, $\phi_i(\tau L)$ stores a significantly larger number of elements than the matrix $L$,which introduce additionly trouble.
I have seen some people efficiently implement the matrix exponential using a tensor product and a straightforward finite difference method, but I have not attempted the combination of finite difference and FFT,
Thx to the answers @lightxbulb, I want to start implementing such a method, but my understanding of the ordering and implementation of 3D grid points is very limited. If you can give a 3D example code of the heat equation ( A quick implementation based on finite differences and FFT, I would be very grateful.)