# A problem in 1D linear finite element method

When applying Galerkin method, we have two conventions, i.e. multiply the test function $v$ at left/right, $(v,u)/(u,v)$. Both ways won't matter for a simple problem like Poisson's equation, since the stiffness matrix $K$ and Mass matrix $M$ are symmetric, and the transpose doesn't change.

However, if there is also first order derivative in the differential equation, then the corresponding assembled matrix is non-symmetric for $(v,du)/(du,v)$, each one is the transpose of the other, then it is a non-unique problem?

I know I got wrong at some point, anyone could help?

• You might wanna change the term "anti-symmetric" to "non-symmetric", the first one means $A^T = -A$. Also there is no non-uniqueness problem if you don't perform integration by parts on the first order term. – Shuhao Cao Sep 6 '13 at 15:41

I teach my students to always multiply from the left, for exactly the reason you mention. More details here:

• Multiplying from the left is indeed a good way of presenting +1 – Shuhao Cao Sep 9 '13 at 14:22

Rule of thumb: The rows in the finite element matrix corresponds to the test function that's been multiplied to the PDE, while the columns in the finite element matrix corresponds to the weak solution (trial function).

Long answer: Say we consider the convection term in the diffusion-convection-reaction equation in a bounded open domain $\Omega$, with a maybe not divergence free convection vector $\mathbf{b}$: $$-\nabla\cdot(A\nabla u) + \underbrace{\mathbf{b}\cdot \nabla u}_{\text{Convection}} + cu = f,$$ with zero Dirichlet boundary condition so that the trial function space for $u$ coincides with the test function space for $v$.

It doesn't matter you multiply the test function $v$ on the left or right: $$\int_{\Omega} v( \mathbf{b}\cdot \nabla u), \quad \text{compare with } \; \int_{\Omega} (\mathbf{b}\cdot \nabla u)v,\tag{1}$$ the corresponding matrix entry will be the same if $v$ is test function. If you perform integration by parts, the convection term will be different: $$-\int_{\Omega} \nabla \cdot(\mathbf{b}v) u, \quad \text{or } \; -\int_{\Omega} u \nabla \cdot(\mathbf{b}v),\tag{2}$$ If we let $u = \sum_{j=1}^N u_j\phi_j$, where $\phi_j$ is the basis function in your finite element space, plugging $u$'s expression into (1), and choose $v = \phi_i$ as the test function to get the $i$-th row the linear equation system: $$\int_{\Omega} A\nabla\Big( \sum_{j=1}^N u_j\phi_j\Big) \cdot \nabla \phi_i + \int_{\Omega} \left( \mathbf{b}\cdot \nabla \Big( \sum_{j=1}^N u_j\phi_j\Big)\right)\phi_i + \int_{\Omega} c \Big( \sum_{j=1}^N u_j\phi_j\Big)\phi_i= \int_{\Omega} f\phi_i.$$ The matrix $B$ corresponding to the second convection term has entry: $$B_{ij} = \int_{\Omega} \phi_i ( \mathbf{b}\cdot \nabla \phi_j) = \int_{\Omega} ( \mathbf{b}\cdot \nabla \phi_j)\phi_i.$$ It doesn't matter you multiply the test function on the left or on the right. The index in the $u$ corresponds to the column, while the index in $v$ corresponds to the row.

However, it does matter the differentiation is performed on which function, the trial function $u$ or the test function $v$. If you use (2) as your convection term in the bilinear form, the matrix $B$ will be different.

It seems to me that you confuse this difference with the "multiply the test function on left or right". Because in 1D, using the notation in your comment, $N N_x$ is matrix generated by (2), for this is performing the differentiation on the test function $v$. $N_x N$ is the matrix generated by (1), this is performing the differentiation on the trial function $u$.

Or you may confuse "multiply the test function on left or right" with the formalism of a non-symmtric bilinear form. In case the bilinear form for convection term is already defined as : $$b[u,v] := \int_{\Omega} v( \mathbf{b}\cdot \nabla u).$$ Notice if you switch $u$ and $v$, it is $$b[v,u] := \int_{\Omega} u( \mathbf{b}\cdot \nabla v) \\ =-\int_{\Omega} \nabla\cdot(\mathbf{b}u) v+ \int_{\partial \Omega} v(\mathbf{b}u)\cdot \mathbf{n}\,dS \\ =-\int_{\Omega} (\nabla\cdot\mathbf{b}) u v-\int_{\Omega} (\mathbf{b}\cdot\nabla u) v + \int_{\partial \Omega} v(\mathbf{b}u)\cdot \mathbf{n}\,dS \\ = -b[u,v]-\int_{\Omega} (\nabla\cdot\mathbf{b}) u v + \int_{\partial \Omega} v(\mathbf{b}u)\cdot \mathbf{n}\,dS.$$ which is totally different, even after integration by parts. This is not about the position where we multiply this test function $v$. Like your said in the comments, if using "left" corresponds to column, "right" corresponds to row, to assemble the finite element matrix, you will get nowhere near correct matrix if divergence of $\mathbf{b}$ is not zero, also boundary terms doesn't vanishes if there exists Neumann boundary.

Maybe the minus sign in (2) makes you think this matrix is anti-symmtric, however it is not. Because the entry on its diagonal is not zero in general: $$B_{ii} = \int_{\Omega} \phi_i ( \mathbf{b}\cdot \nabla \phi_i) \neq 0.$$ A matrix with non-zero diagonal can't be anti-symmetric.

• thanks a lot! though i am not familiar with this DCR eqn, it's mathematic form is quite similar with what I am working on. You are definitely right that I may confuse sth, let me get a few minutes to think about it, may get back to you soon :) – lorniper Sep 6 '13 at 17:55
• @user4532 Sure :) – Shuhao Cao Sep 6 '13 at 18:02
• I am wrong on anti-symmetric(in fact i mean sth like[-1 -1; 1 1]). However, i think maybe we think differently, you prefer "u corresponds to the column, while the index in v corresponds to the row", while I always consider, for instance, in your eq.(1), I assume on the left the entity is 'column' and on the right is 'row', then it's a outer product. To be more specific, let's suppose the basis$\phi=[1-x;x]$,then $\int^1_0 N_xN^Tdx=[-0.5\,-0.5;0.5\,0.5]$, while $\int^1_0 NN^T_xdx=[-0.5\,0.5;-0.5\,0.5]$ – lorniper Sep 6 '13 at 20:48
• @shawniper "left->column" and "right->row" are a misleading way of assembling finite element matrix, because you are associating something communtative (scalar multiplication) with something non-communtative (matrix multiplication), it is essentially performing integration by parts in your case. If considering (1), this is not even correct because $\mathbf{b}$ is not divergence free, the matrix for $\int v(\mathbf{b}\cdot \nabla u)$ term using your rule is actually the matrix for $\int u(\mathbf{b}\cdot \nabla v)$, which is not correct term even after integration by parts. – Shuhao Cao Sep 8 '13 at 22:34

We usually write linear algebra equations as $Au=b$, which can be rewritten to \begin{equation} v^T A u = v^T b \qquad \forall v\in \mathbb R^n. \end{equation}

From this, you see that the convention in linear algebra is the test function on the left, while in PDEs, we have it on the right. Thus, for a nonsymmetric bilinear form, the safe bet for integrating the matrix entries is \begin{equation} a_{ij} = a(u_j, v_i). \end{equation}