% 'symbolic_least_square.m'

% David Pan, UAH

syms p1 p2 p E2(p1, p2)
p =[p1;p2]
syms E2(p1, p2)
V = [2, 1; 3, 1; 4, 1];
y = [5 7 9]';
E2(p1,p2) = simplify((p.')*(V')*V*p-(p.')*(V')*y-y'*V*p+y'*y);
fsurf(p1, p2, E2, [-100 100 -100 100]); colorbar;
fsurf(p1, p2, E2, [1 3 0 2]); colorbar