10 Use MATLABOctave to compute both sides of the triangle in

10. Use MATLAB/Octave to compute both sides of the triangle inequality x+yll x/+ly for some random vectors x and y and for each of the norms (1, 2 and oo) that we defined. Verify that for these examples the inequality is true.

Solution

choose any dimension I have chosen 3

Here is the matlab code

% two random vectors of dimension 3

x = rand(3,1)

y = rand(3,1)

%check inequality for 1-norm

norm(x,1)

norm(y,1)

norm(x+y,1)

norm(x,1)+ norm(y,1)

%Now check for 2-norm

norm(x,2)

norm(y,2)

norm(x+y,2)

norm(x,2)+ norm(y,2)

% Now check for infinity norm

norm(x,inf)

norm(y,inf)

norm(x+y,inf)

norm(x,inf)+ norm(y,inf)

 10. Use MATLAB/Octave to compute both sides of the triangle inequality x+yll x/+ly for some random vectors x and y and for each of the norms (1, 2 and oo) that

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site