% Here are the functions needed for Practical 1
% To use in Matlab, functions should be split into separate, appropriately
% named files


function [s] = EuclideanNorm(v)

s=0;

% using for loops
for i = 1:length(v)
    
    s = s+v(i)^2;
    
end

s = sqrt(s);

% or using vector methods

s = sqrt(v' * v);

end



function [s] = ManhattanNorm(v)

s=0;

% using for loops
for i = 1:length(v)
    
    s = s + abs(v(i));
    
end

% or using vector methods
s = sum(abs(v));

end

function [s] = MaxValueNorm(v)

s=0;

% using for loops
for i = 1:length(v)
    
    if abs(v(i)) > s
        
        s = abs(v(i));
        
    end
end

% or using vector methods
s = max(abs(v));

end

function [s] = DotProduct(v1, v2)

s=0;

% using for loops
for i = 1:length(v1)
    
    s = s + v1(i)*v2(i);
    
end

% or using vector methods
s = v1' * v2;

end




% for  question 5(2), the region wich satisfied |a|<=1 is a filled round region with center at 'a' (-3, 4)
% and radius of 1.  Similar for |b|<=1.

% for question 5(3), the formula of the line which seperates two region is y=1/3*x.
% for visualization, you may do
% hold on; plotv(a) ; plot(b); plotv(a+b); 
% 


% Note, this document is modified based on Peter Bell's documentation.

