Gently push my non-Positive Definite matrix back into the set of Positive Definite matrices

I have a matrix $\eta$ that should be Positive Definite but it is not. Is there a numerical method to gently push my non-Positive Definite matrix back into the set of Positive Definite matrices?

Background

I need to evaluate the following integral: $$I=\int_{\mathcal{D}}\phi(\vec{x})\psi(\vec{x}) d\vec{x}^2$$ where both functions are real and my vector notation is just implying integration in a 2D plane.

I expand my functions into a set of basis functions ($B_{j}(\vec{x})$) that are not orthogonal. Why not orthogonal? Because $\mathcal{D}$ is arbitrary and once a I have a $\mathcal{D}$ I only want to spend computer time once to do numerical integrations but be able to calculate an unlimited number of $I$ values quickly. Also some times I'm given the basis functions that I must work with.

I write: $$\phi(\vec{x})\approx \sum_{j=1}^{n} a_{J} B_{j}(\vec{x})$$ and $$\psi(\vec{x})\approx \sum_{j=1}^{n} b_{J} B_{j}(\vec{x})$$ This lets me think of my functions as vectors: $$\phi(\vec{x})\rightarrow \left<a_1,a_2,a_3,\ldots,a_n\right>^{T}=\vec{\phi}$$ $$\psi(\vec{x})\rightarrow \left<b_1,b_2,b_3,\ldots,b_n\right>^{T}=\vec{\psi}$$ I can now separate my geometry ($\mathcal{D}$) from the instance of my functions. $$I\approx\sum_{i=1}^{n}\sum_{j=1}^{n} a_{i} b_{j} \int_{\mathcal{D}} B_{i}(\vec{x}) B_{j}(\vec{x}) d\vec{x}^2$$ Notice because of my lack of orthogonality I do not get those beautiful Kronecker delta things so I'm left with double sums. I can rewrite as: $$I\approx \vec{\phi}^{T}\eta\vec{\psi}$$ where $$\eta_{i,j}=\int_{\mathcal{D}} B_{i}(\vec{x}) B_{j}(\vec{x}) d\vec{x}^2$$

Some properties to keep in mind:

• $\eta$ is symmetric $\eta^{T}=\eta$
• $\eta$ is of full rank but the singular values span many orders of magnitude.
• $\eta$ is Positive Definite in theory (Challenge this statement if you think it is wrong.)

The Problem

Because of numerical integration errors $\eta$ is not Positive Definite but it does have full rank.

The Question

Is there a numerical method to gently push my non-Positive Definite matrix back into the set of Positive Definite matrices?

• Is diagonalizing it and replacing the negative eigenvalues an option? – joriki Oct 13 '12 at 15:04
• I tried taking the absolute value of the eigen-values then re-building but it remained non-Positive Definite. I also made sure that my eigen-vectors were real. – c186282 Oct 13 '12 at 15:13
• Then there's more wrong in your code than just integration errors. A real symmetric matrix with positive eigenvalues is almost by definition positive-definite. – joriki Oct 13 '12 at 15:21
• Yes I agree something somewhere is going bad most likely in my code. I have played with the essence of small ($3\times 3$) positive-definite matrices testing everything I would expect to be true and I get what I expect. But when I work with my real problem that has a $408\times 408$ and this is a small case, I get unexpected results. I do not what to drag you or anyone into the depths of my code but I'm looking for some silly things to check and think about. – c186282 Oct 14 '12 at 2:09
• It's either an outright error or a rounding problem. I suspect the basis functions that are being forced upon you are nearly linearly dependent? You might try orthogonalizing them first, but I suspect that might lead to the same rounding problems. If you can get a hold of J.M., he might be able to help; he knows quite a lot about such things. – joriki Oct 14 '12 at 7:03