I am running into issues when attempting to shift a Hessian to be positive definite for an optimization problem in Matlab. An example of my problem is:
H=[1 2 2;
2 3 2;
1 3 1];
[V,D]=eig(H);
While H*V-V*D
, as it should, essentially equals zero:
V*D*V'
does not provide the original H matrix
I actually tried to run your code:
H = [
1 2 2;
2 3 2;
1 3 1
];
[V,D] = eig(H);
test = norm(H*V-V*D,inf) / norm(V*D,inf);
and I'm seeing no obvious problems with the example you posted. The eigenvalues and vectors that I get satisfy their defining equation with high accuracy:
test = 7.57596318689868e-16
On the top of that, as @kpg987 pointed out, you have to use the inverse of V, not the transposed version of V. And if you perform the following test:
test = V * D * inv(V);
You will obtain your original hessian (or something very very close to it).