% par.m 96/07/30
%
% Program to plot contours of paraboloid
%
% z=f(x,y)=4x^2+y^2
%

    mmm=3.5;
    np=20;
    x=3.5*(-np:np)/np;
    y=3.5*(-np:np)/np;
    [X,Y]=meshgrid(x,y);
    Z=4*X.^2+Y.^2;
    v=[1 5 10];
    hold off;
    contour(x,y,Z,v,'w-');
    axis square;
    text(.2,0,'c=1');
    text(.7,-.8,'c=5');
    text(1,-2,'c=10');
    xlabel('x');
    ylabel('y');
    hold on;

% Plot gradient vector at (1,1)

    px=1;
    py=1;
    gp=[8*px; 2*py];
    ale=atan(gp(2)/gp(1));
    len=.125;
    lenar=.25
    plot([px],[py],'o');
    p1=[px; py];
    p2=p1+norm(gp)*len*[cos(ale); sin(ale)];
    arrow(p1,p2,norm(gp)*len*lenar);
    
% Plot gradient vector at (sqrt(1.25),0)

    px=sqrt(1.25);
    py=0;
    gp=[8*px; 2*py];
    ale=atan(gp(2)/gp(1));
    len=.125;
    lenar=.25
    plot([px],[py],'o');
    p1=[px; py];
    p2=p1+norm(gp)*len*[cos(ale); sin(ale)];
    arrow(p1,p2,norm(gp)*len*lenar);

% Plot gradient vector at (0,sqrt(5))

    py=sqrt(5);
    px=0;
    gp=[8*px; 2*py];
    ale=atan(gp(2)/gp(1));
    len=.125;
    lenar=.25
    plot([px],[py],'o');
    p1=[px; py];
    p2=p1+norm(gp)*len*[cos(ale); sin(ale)];
    arrow(p1,p2,norm(gp)*len*lenar);
    hold off;
