# Discontinuous Galerkin - Inhomogeneous Dirichlet B.C. for 1D Poisson Equation

I am trying to get some code working for the 1D Poisson equation using the textbook: Nodal Discontinuous Galerkin Methods Algorithms, Analysis, and Applications.

I use the following formulation (for a homogeneous case): In order to account for inhomogeneous cases, the textbook proposes the following: where $\mathcal A$ is given from the homogeneous case. When I attempt to implement the added term on the right-hand side of the equation above, I obtain the following response, which seems to almost respond correctly; however, the first and last terms deviate greatly from their specified b.c: I implement the extra rhs term with the following code:

e = zeros((basisdegree+1),numelements);
enp = e; enp(end) = 1; e1 = e; e1(1) = 1;
extraterm = Dr*(enp*b - e1*a);


Where e is just a vector the size of the solution u, with 1 located in the first and last element. Dr is the same as in the homogeneous equations which are $\mathcal{M}^{-1} \mathcal{S}$.