From: John Wong on
Suppose f(x,y) = sin(3y-x^2+1)+cos(2y^2-2x)
a) produce a labeled contour plot for -2 <= x <= 2, -1<= y<= 1

b) Based on the contour plot you found in a) estimate the coordinates of two saddle
points of the function in the region S defined in a). Mark the points using the Data
Cursor.


My code is as follows:
[code]
x=linspace (-2,2,25); y=linspace (-1,1,25);
[x y]=meshgrid (x,y)
z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
[C h]=contour (x,y,z); % the "handle" matrix [C h] holds the graph for labelling
clabel (C,h); % the clabel function labels the level curves
[/code]

output image: http://i47.tinypic.com/2dalvyu.jpg

I don't really know how to tell from the graph. I tried to solve it using second derivative test in matlab, but the solution is very weird, which I can't really use it at this point.

Is it true that the the gap (pointy-gap) between the two lightest green lines are the two saddle points???

Any help is appreciated. Thank you
From: Aaron Clarke on
The the pointy gaps between the two lightest green lines are the two saddle points. Roughly located at (0.5576,-1.0000) and (-1.0198,0.2598). It's a bit easier to tell if you plot your data as a surface plot:

[x y]=meshgrid (linspace (-2,2,25),linspace (-1,1,25));
z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
figure;
surf(x,y,z);
xlabel('x'); ylabel('y');
cameratoolbar('NoReset');
cameratoolbar('SetMode', 'orbit');

Cheers,

Aaron

"John Wong" <gokoproject(a)gmail.com> wrote in message <i0u2a0$gi9$1(a)fred.mathworks.com>...
> Suppose f(x,y) = sin(3y-x^2+1)+cos(2y^2-2x)
> a) produce a labeled contour plot for -2 <= x <= 2, -1<= y<= 1
>
> b) Based on the contour plot you found in a) estimate the coordinates of two saddle
> points of the function in the region S defined in a). Mark the points using the Data
> Cursor.
>
>
> My code is as follows:
> [code]
> x=linspace (-2,2,25); y=linspace (-1,1,25);
> [x y]=meshgrid (x,y)
> z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
> [C h]=contour (x,y,z); % the "handle" matrix [C h] holds the graph for labelling
> clabel (C,h); % the clabel function labels the level curves
> [/code]
>
> output image: http://i47.tinypic.com/2dalvyu.jpg
>
> I don't really know how to tell from the graph. I tried to solve it using second derivative test in matlab, but the solution is very weird, which I can't really use it at this point.
>
> Is it true that the the gap (pointy-gap) between the two lightest green lines are the two saddle points???
>
> Any help is appreciated. Thank you
From: John D'Errico on
"John Wong" <gokoproject(a)gmail.com> wrote in message <i0u2a0$gi9$1(a)fred.mathworks.com>...
> Suppose f(x,y) = sin(3y-x^2+1)+cos(2y^2-2x)
> a) produce a labeled contour plot for -2 <= x <= 2, -1<= y<= 1
>
> b) Based on the contour plot you found in a) estimate the coordinates of two saddle
> points of the function in the region S defined in a). Mark the points using the Data
> Cursor.
>
>
> My code is as follows:
> [code]
> x=linspace (-2,2,25); y=linspace (-1,1,25);
> [x y]=meshgrid (x,y)
> z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
> [C h]=contour (x,y,z); % the "handle" matrix [C h] holds the graph for labelling
> clabel (C,h); % the clabel function labels the level curves
> [/code]
>
> output image: http://i47.tinypic.com/2dalvyu.jpg
>
> I don't really know how to tell from the graph. I tried to solve it using second derivative test in matlab, but the solution is very weird, which I can't really use it at this point.
>
> Is it true that the the gap (pointy-gap) between the two lightest green lines are the two saddle points???
>
> Any help is appreciated. Thank you

John,

Since you have done the work, I'll help you.

A saddle point is easy to find from a contour plot.
It is a point where a pair of contour lines (of the
same value) would almost "try" to cross. Those
green lines that almost touch are exactly that.

The locally linear approximation used inside the
contour engine will fail to approximate the
saddle point correctly anyway, even if you had
the exactly correct contour level at which the
saddle point happens. So it looks the way you
see it on the plot.

In fact, there appears to be a third saddle point
on this plot, just near the edge.

John