Example 1: Unconstrained Optimization (Exercise 36)
> f := y/(1+x^2+y^2);
>
Three plots of this function appear on p. 636 of the text. Here are the Maple equivalents (see also the worksheet for Section 15.1).
> plot3d( f, x=-5..5, y=-5..5, orientation=[-45,45], title="Figure 16 a" );
> plot3d( f, x=-5..5, y=-5..5, style=patchcontour, orientation=[-45,45], title="Figure 16 b" );
>
plot3d( f, x=-5..5, y=-5..5, style=contour, orientation=[-90,0],
title="Figure 16 c" );
>
From these pictures it is clear that there is a unique global maximum and minimum for this function. The critical points appear to have y=0 and the maximum occurs with x>0 while the minimum occurs with x<0.
>
New, let's try to locate these point via calculus.
>
> fx := diff( f, x );
> fy := diff( f, y );
> fy := simplify( fy );
>
> solve( {fx=0, fy=0}, {x,y} );
>
Thus, Maple finds two critical points. To classify these points as local extrema, use the Second Derivative Test:
>
> fxx := diff( f, x,x );
> fyy := diff( f, y,y );
> fxy := diff( f, x,y );
>
> discr := simplify( fxx*fyy-fxy^2 );
>
One critical point is (0,1):
> cp1 := {x=0,y=1};
> eval( discr, cp1 );
> eval( fxx, cp1 );
>
With D>0 and fxx<0, this critical point is a local maximum.
>
The second critical point is (0,-1):
> cp2 := {x=0,y=-1};
> eval( discr, cp2 );
> eval( fxx, cp2 );
>
With D>0 and fxx>0, this critical point is a local maximum.
>