{VERSION 4 0 "APPLE_PPC_MAC" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 2" -1 4 1 {CSTYLE "" -1 -1 "Times " 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 2 1 0 1 0 2 2 0 1 } {PSTYLE "Heading 1" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 2" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 8 2 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "MATH 243-015" }}{PARA 0 " " 0 "" {TEXT -1 32 "Analytic Geometry and Calculus C" }}{PARA 0 "" 0 " " {TEXT -1 19 "Prof. D. A. Edwards" }}{PARA 0 "" 0 "" {TEXT -1 14 "Cop yright 2001" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 256 "" 0 "" {TEXT -1 48 "Section 15.6: Gradients and \+ Associated Concepts " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 133 "Today we'll be using different plot devices as well as vectors. We begin by defining two functions, f2 and f3, of s everal variables:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 91 "restart;\nwith (plots):\nwith(plottools):\nwith(linalg):\nf2:=cos(x*y^3);\nf3:=sin(x+ 3*y)*exp(z);" }}}{SECT 1 {PARA 257 "" 0 "" {TEXT -1 38 "Gradients and \+ Directional Derivatives\n" }}{EXCHG {PARA 257 "" 0 "" {TEXT -1 1 " " } {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 49 "To calculate \+ the gradient of a function, use the " }{TEXT 0 4 "grad" }{TEXT -1 156 " command. The first argument is the function; the second is a bracke ted list of the variables with respect to which you want to take the d erivative. They " }{TEXT 256 4 "MUST" }{TEXT -1 24 " be in the proper order!" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "gradf2:=grad(f2,[x,y]); \ngradf3:=grad(f3,[x,y,z]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 195 "M aple doesn't care about how many letters are in your functions. There fore, if you don't list the proper number of variables, Maple will sti ll return an answer, though it may not make any sense:" }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 15 "grad(f3,[x,y]);" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 109 "Recall the the directiona l derivative in a certain direction is just the dot product of the gra dient and the " }{TEXT 257 4 "UNIT" }{TEXT -1 102 " vector pointing in that direction. Therefore, to find the directional derivative of f2 a t the point (" }{XPPEDIT 18 0 "Pi/2,1;" "6$*&%#PiG\"\"\"\"\"#!\"\"F%" }{TEXT -1 81 ") in the direction of (2,3), we first define and normal ize the direction vector:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "a:=vec tor([2,3]);\nu:=normalize(a);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 " Once we've done that, we can substitute in the point (" }{XPPEDIT 18 0 "Pi" "6#%#PiG" }{TEXT -1 31 "/2,1) and take the dot product:" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "g2:=eval(evalm(gradf2),[x=Pi/2,y=1] );\ndfdu:=dotprod(g2,u);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 272 "Reca ll that the gradient points in the direction of maximum increase, and \+ any direction perpendicular to it points in a direction of constant f2 . So we construct the unit vectors parallel and perpendicular to gradf 2. We also construct the derivatives in those directions:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 109 "g3:=vector([-g2[2],g2[1]]);\nn2:=normalize (g2);\ndfdg:=dotprod(n2,g2);\nn3:=normalize(g3);\ndfdp:=dotprod(n3,g2) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 117 "To illustrate the concept, \+ we create the following graph:\n1) We plot the surface f2, choosing a s a contour level f2(" }{XPPEDIT 18 0 "Pi" "6#%#PiG" }{TEXT -1 424 "/2 ,1)=0.\n2) We plot (in green) the vector whose first two components \+ are u and whose third component is dfdu (the directional derivative in the direction of u).\n3) We plot (in blue) the vector whose first tw o components are n2 (parallel to the gradient) and whose third compone nt is dfdg.\n4) We plot (in red) the vector whose first two component s are n3 (perpendicular to the gradient) and whose third component is \+ dfdp." }}{PARA 0 "" 0 "" {TEXT -1 107 "We begin by creating the vector s we need, which is the tail point for each vector, and each vector it self. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 145 "tail:=vector([Pi /2,1,eval(f2,[x=Pi/2,y=1])]);\ntip2:=vector([u[1],u[2],dfdu]);\ntip3:= vector([n2[1],n2[2],dfdg]);\ntip4:=vector([n3[1],n3[2],dfdp]);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "Then we plot the result:" } {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 320 "p1:=pl ot3d(f2,x=Pi/4..3*Pi/4,y=0.5..1.5,style=wireframe,axes=normal):\np1a:= contourplot3d(f2,x=Pi/4..3*Pi/4,y=0.5..1.5,contours=[0],color=black,th ickness=2):\np2:=arrow(tail,tip2,0.05,0.1,0.1,color=green):\np3:=arrow (tail,tip3,0.05,0.1,0.1,color=blue):\np4:=arrow(tail,tip4,0.05,0.1,0.1 ,color=red):\ndisplay(p1,p1a,p2,p3,p4);" }}}{EXCHG {PARA 257 "" 0 "" {TEXT -1 8 "Exercise" }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 49 "Calculate the directional derivative of g(x,y,z)=" } {XPPEDIT 18 0 "cos^2" "6#*$%$cosG\"\"#" }{TEXT -1 66 " (x*y) + log(z) \+ in the direction of (-1,2,3) at the point (0,0,1)." }{MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 8 "Solution" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "First we define the function and calculate the gradient there:" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 64 "g:=cos(x*y)^2+log(z);\ngvec:=eval(grad(g,[x, y,z]),[x=0,y=0,z=1]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 84 "Then we \+ calculate the unit vector in the desired direction and take the dot pr oduct:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "ug:=normalize(vector([-1, 2,3]));\ndgdu:=dotprod(gvec,ug);" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 257 "" 0 "" {TEXT -1 14 "Tangent P lanes" }}{EXCHG {PARA 257 "" 0 "" {TEXT -1 1 " " }{MPLTEXT 1 0 0 "" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 210 "Recall that for a three-dimensio nal level surface, the gradient is parallel to the normal line and per pendicular to the tangent plane. To illustrate this concept, we begin by constructing the level surface f3=" }{XPPEDIT 18 0 "2^(-1/2)" "6#) \"\"#,$*&\"\"\"F'F$!\"\"F(" }{TEXT -1 38 ". On this level surface is t he point (" }{XPPEDIT 18 0 "Pi" "6#%#PiG" }{TEXT -1 47 "/4,0,0), and t hat's where we take the gradient:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 116 "tail2:=vector([Pi/4,0,0]);\ng3d:=eval(evalm(gradf3), [x=Pi/4,y=0,z=0]);\nnarr:=arrow(tail2,g3d,0.1,0.2,0.1,color=blue):" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "The tangent plane is given by tho se vectors (x,y,z) such that (x,y,z)-(" }{XPPEDIT 18 0 "Pi" "6#%#PiG" }{TEXT -1 41 "/4,0,0) is perpendicular to the gradient:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "xmx0:=evalm(vector([x,y,z])-tail2); \ndotprod(xmx0,g3d)=0;\ntplan:=solve(%,z);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 178 "Now we plot the following three things together:\n1) A \+ graph of the surface near the point where we took the gradient.\n2) T he gradient vector (in blue), showing the normal line." }}{PARA 0 "" 0 "" {TEXT -1 59 "3) The tangent plane to the surface.\nHere we must \+ use the " }{TEXT 0 11 "constrained" }{TEXT -1 16 " option, or the " } {TEXT 0 5 "arrow" }{TEXT -1 28 " won't look like the normal." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 237 "p5:=implicitplot3d(f3=1/sqr t(2),x=0..Pi/2,y=-1..1,z=-1..1,style=patchcontour,axes=normal):\np6:=p lot3d(tplan,x=0..Pi/2,y=-0.5..1,style=wireframe):\ndisplay(p5,p6,narr, orientation=[-3,90],view=[0..2.2,0..2.2,-1.1..1.1],scaling=constrained );" }}}{EXCHG {PARA 257 "" 0 "" {TEXT -1 8 "Exercise" }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "Find the equation of the tan gent plane to g(x,y,z)=" }{XPPEDIT 18 0 "cos^2" "6#*$%$cosG\"\"#" } {TEXT -1 37 " (x*y) + log(z) at the point (0,0,1)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 8 "Sol ution" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "We use the definitions fr om before:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "xmxg:=vector([x-0,y-0 ,z-1]);\ndotprod(xmxg,gvec)=0;" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 256 "" 0 "" {TEXT -1 39 "Section 15.7: Extr ema and Saddle Points" }}{EXCHG {PARA 256 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 231 "\nRecall that wherever the gradient of a function vanishes, that point is a candidate for the location of an e xtremum. To check and see if the extremum exists or whether we have a saddle point, we look at the following expression:\n" }{XPPEDIT 18 0 "diff(f(x,y),x,x)*diff(f(x,y),y,y)-diff(f(x,y),x,y)^2\n" "6#,&*&-%%dif fG6%-%\"fG6$%\"xG%\"yGF+F+\"\"\"-F&6%-F)6$F+F,F,F,F-F-*$-F&6%-F)6$F+F, F+F,\"\"#!\"\"" }{TEXT -1 71 "\nBut this is just the determinant of th e Hessian matrix, called by the " }{TEXT 0 7 "hessian" }{TEXT -1 54 " \+ command. The first argument is the function; as with " }{TEXT 0 4 "gra d" }{TEXT -1 84 ", the second is the set of variables with respect to \+ which you are differentiating:\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "hessian(f(x,y),[x,y]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "Once w e have the Hessian, all we need to do is take its determinant, which w e do using the " }{TEXT 0 3 "det" }{TEXT -1 9 " command:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "det(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "As an example, we look for some extrema of the following \+ function:. " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 111 "g1:=x^2+y^2;\nplot3 d(g1,x=-1..1,y=-sqrt(1-x^2)..sqrt(1-x^2),style=patchcontour,axes=norma l,orientation=[51,72]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 164 "It sh ould be pretty clear that there is only one minimum at the origin. It 's usually easiest to take the partial derivatives separately and set \+ them equal to zero:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "sys1:=\{diff (g1,x)=0,diff(g1,y)=0\};\ncrit1:=solve(sys1,\{x,y\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "Therefore, we see that the only critical \+ point is at the origin, as suspected." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "h1:=hessian(g1,[x,y]);\neval(det(h1),[x=0,y=0]);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "Therefore, since " }{XPPEDIT 18 0 "f[xx] = 2;" "6#/&%\"fG6#%#xxG\"\"#" }{TEXT -1 125 ">0 and the determi nant of the Hessian is positive, there is a minimum at the origin.\n\n Next we look at the following function:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 106 "g2:=x*y;\nsad:=plot3d(g2,x=-2..2,y=-1..1,style=patchcontour,a xes=normal,orientation=[72,61]):\ndisplay(sad);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 166 "It sh ould be reasonably clear that there is a saddle point at the origin. \+ It's usually easiest to take the partial derivatives separately and se t them equal to zero:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "sys2:=\{di ff(g2,x)=0,diff(g2,y)=0\};\ncrit2:=solve(sys2,\{x,y\});\n\n \+ " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 143 "Therefore, we see tha t we obtain the origin as the critical point, as expected. Taking the determinant of the Hessian at that point, we obtain" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "h2:=hessian(g2,[x,y]);\neval(det(h2),[x=0 ,y=0]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 111 "Since the determinant of the Hessian matrix is less than zero, we see that the origin is in deed a saddle point." }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 257 "" 0 "" {TEXT -1 8 "Exercise" }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 65 "As an exercise, find and characterize all the critical po ints of " }{XPPEDIT 18 0 "k(x,y) = x^3+3*x*y-y^2;" "6#/-%\"kG6$%\"xG% \"yG,(*$F'\"\"$\"\"\"*(F+F,F'F,F(F,F,*$F(\"\"#!\"\"" }{TEXT -1 1 "." } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 8 "Solution" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "First we define \+ the function and calculate the gradient and determinant of the Hessian :" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "k:=x^3+3*x*y-y^2;\nkg:=grad(k, [x,y]);\nhhes:=hessian(k,[x,y]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "We then solve for all the critical points and plug into the Hessia n:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "rts:=solve(\{kg[1],kg[2]\},\{ x,y\});\neval(evalm(hhes),rts[1]);\ndet(%);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 141 "Since the determinant of the Hessian is negative at (0 ,0), we see that this critical point is a saddle point. Next we check the other point:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "eval(e valm(hhes),rts[2]);\ndet(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 128 " The determinant of the Hessian is positive, and the upper-left entry i s negative. Thus there is a local maximum at (-3/2,-9/4)." }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 256 "" 0 "" {TEXT -1 34 "Section 15 .8: Lagrange Multipliers" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 35 "We begin by defining a function g2:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 106 "g2:=x*y;\nsad:=plot3d(g2,x= -2..2,y=-1..1,style=patchcontour,axes=normal,orientation=[72,61]):\ndi splay(sad);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 149 "Maple has no special functions for Lagrange multiplier s, so we must do them by hand. Let's find the maximum of the function f(x,y)=xy on the circle " }{XPPEDIT 18 0 "x^2+y^2=1" "6#/,&*$%\"xG\" \"#\"\"\"*$%\"yGF'F(F(" }{TEXT -1 34 ". Here's a plot of the situatio n:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 176 "gt:=eval(g2,[x=cos(t),y=sin( t)]);\ncurveeq:=vector([cos(t),sin(t),gt]);\ncurve:=spacecurve(curveeq ,t=0..2*Pi,color=black,thickness=4):\ndisplay([sad,curve],orientation= [114,49]);\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 179 "Note that in thi s graph we parametrized the curve by (cos(t),sin(t)). If we substitut e these values into g2, we can take the derivative with respect to t t o get the right answer:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 " rts:=solve(diff(gt,t)=0,t);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 177 "T hese expressions give us two (but not all) of the extrema. (That's be cause we are trying to solve for the roots of a trigonometric expressi on.) These correspond to the points" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "eval(evalm(curveeq),t=rts[1]);\neval(evalm(curveeq),t=rts[2]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 483 "Thus we see that the first poi nt corresponds to a maximum and the second to a minimum. Now we use t he method of Lagrange multipliers.\nThe first equation is the constrai ning equation (the equation for the circle).\nThe second is the gradie nt equation, which we split into three equations. Note that we write \+ it as grad g2-lambda*grad(lhs(eq1)) since eq1 is really g(x,y)=1. Als o note that the quantity resulting must equal zero, so in Maple we don 't need to put it into an equation." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 88 "eq1:=x^2+y^2=1;\ngradeq:=grad(g2-lambda*lhs(eq1),[x,y]);\nsys3:=\{ eq1,gradeq[1],gradeq[2]\};" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "Now tjhese equations must be solved for the unknowns x, y, and " } {XPPEDIT 18 0 "lambda" "6#%'lambdaG" }{TEXT -1 1 ":" }{MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "ans:=solve(sys3,\{x,y,l ambda\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 125 "Note that we don't \+ have our expressions explicitly listed; instead, we have them listed i n terms of the root of the equation " }{XPPEDIT 18 0 "2*z^2-1 = 0;" "6 #/,&*&\"\"#\"\"\"*$%\"zGF&F'F'F'!\"\"\"\"!" }{TEXT -1 41 ". In order \+ to evaluate them, we use the " }{TEXT 0 9 "allvalues" }{TEXT -1 61 " c ommand, which can operate on only one expression at a time:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "ans1:=allvalues(ans[1]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "ans2:=allvalues(ans[2]);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "Now we have all four extrema, whic h correspond to the points" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 111 "[ans 1[1],eval(g2,ans1[1])];\n[ans1[2],eval(g2,ans1[2])];\n[ans2[1],eval(g2 ,ans2[1])];\n[ans2[2],eval(g2,ans2[2])];" }}}{EXCHG {PARA 257 "" 0 "" {TEXT -1 9 "Exercise\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "Find th e extrema of the function g2 on the ellipse " }{XPPEDIT 18 0 "x^2+2*y^ 2 = 1.;" "6#/,&*$%\"xG\"\"#\"\"\"*&F'F(*$%\"yGF'F(F($F(\"\"!" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 8 "Solution" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 90 "First we d efine the constraint and gradient equations. We use the definitions f rom above." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 93 "eq1e:=x^2+2*y^2=1;\ng radeq:=grad(g2-lambda*lhs(eq1e),[x,y]);\nsyse:=\{eq1e,gradeq[1],gradeq [2]\};" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "Now these equations mus t be solved for the unknowns x, y, and " }{XPPEDIT 18 0 "lambda" "6#%' lambdaG" }{TEXT -1 12 ", using the " }{TEXT 0 9 "allvalues" }{TEXT -1 9 " command:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "solve(syse, \{x,y,lambda\});" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "anse:=allvalues (%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "Now we have the extrema, \+ which correspond to the points" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 111 " [anse[1],eval(g2,anse[1])];\n[anse[2],eval(g2,anse[2])];\n[anse[3],eva l(g2,anse[3])];\n[anse[4],eval(g2,anse[4])];" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" } }}}}{MARK "4" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }