{VERSION 1 0 "X11/Motif" "1.0"}{GLOBALS 1 1}{FONT 0 "-adobe-helve
tica-bold-r-normal--14-*" "helvetica" "Helvetica-Bold" 8 14 0 "He
lvetica-Bold" 12}{FONT 1 "-adobe-times-medium-r-normal--14-*" "ti
mes" "Times-Roman" 4 14 64 "Times-Roman" 12}{FONT 2 "Courier New"
 "Courier New" "Courier" 4 12 192 "Courier" 10}{SCP_R 1 0 105
{COM_R 2 0{TEXT 1 76 "LANGRAGE MULTIPLIERS\015Alastair Rough: ROU
GH@MANADON-ENGINEERING-COLLEGE.AC.UK"}}{COM_R 3 0{TEXT 1 0 ""}}
{COM_R 4 0{TEXT 1 10 "EXAMPLE 1."}}{COM_R 5 0{TEXT 1 0 ""}}{COM_R
 6 0{TEXT 1 137 "The aim is to maximise or minimise a function f(
x,y) subject to a constraint that q(x,y) = 0. This is achieved by
 forming a new function:"}}{COM_R 7 0{TEXT 1 98 "                
                                                      g(x,y) = f(
x,y) + mu q(x,y)\015"}}{COM_R 8 0{TEXT 1 38 "where mu  is the Lag
range multiplier. "}}{COM_R 9 0{TEXT 1 0 ""}}{COM_R 10 0{TEXT 1 
45 "Calculate the maximum and minimum values of :"}}{INP_R 11 0 "
> "{TEXT 0 47 "f := x^2 + y^2;                                "}}
{OUT_R 12 0 11{DAG :3n3\`f`+5*3n3\`x`j2x0002j2x0001*3n3\`y`p7p9}}
{COM_R 13 0{TEXT 1 0 ""}}{COM_R 14 0{TEXT 1 11 "subject to:"}}
{INP_R 15 0 "> "{TEXT 0 84 "q := x^2+ y^2+ 2*x - 2*y + 1;        
                                  #equation (1)"}}{OUT_R 16 0 15
{DAG :3n3\`q`+B*3n3\`x`j2x0002j2x0001*3n3\`y`p7p9p5p7pCi2x0002p9p
9}}{COM_R 17 0{TEXT 1 0 ""}}{COM_R 18 0{TEXT 1 18 "by forming g(x
,y):"}}{INP_R 19 0 "> "{TEXT 0 44 "g := f + mu*q;                
              "}}{OUT_R 20 0 19{DAG :3n3\`g`+7*3n3\`x`j2x0002j2x0
001*3n3\`y`p7p9*5n3\`mu`p9+Bp4p9pBp9p5p7pCi2x0002p9p9p9p9}}{COM_R
 21 0{TEXT 1 0 ""}}{COM_R 22 0{TEXT 1 61 "Differentiate g with re
spect to x and then with respect to y."}}{INP_R 23 0 "> "{TEXT 0 
84 "exp1:= Diff(g,x);      exp1:= diff(g,x);                     
         #equation (2) "}}{OUT_R 24 0 23{DAG :3n4\`exp1`(3n4\`Dif
f`,3+7*3n3\`x`j2x0002j2x0001*3n3\`y`pDpF*5n3\`mu`pF+BpApFp11pFpBp
Dp12i2x0002pFpFpFpFpB}}{OUT_R 25 0 23{DAG :3n4\`exp1`+5n3\`x`j2x0
002*5n3\`mu`j2x0001+5p5p7p7pCpCpC}}{INP_R 26 0 "> "{TEXT 0 83 "ex
p2:= Diff(g,y);      exp2:= diff(g,y);                           
   #equation (3)"}}{OUT_R 27 0 26{DAG :3n4\`exp2`(3n4\`Diff`,3+7*
3n3\`x`j2x0002j2x0001*3n3\`y`pDpF*5n3\`mu`pF+BpApFp11pFpBpDp12i2x
0002pFpFpFpFp12}}{OUT_R 28 0 26{DAG :3n4\`exp2`+5n3\`y`j2x0002*5n
3\`mu`j2x0001+5p5p7i2x0002pCpCpC}}{COM_R 29 0{TEXT 1 0 ""}}{COM_R
 30 0{TEXT 1 137 "The values of x, y and mu which give the condit
ional maxima or minima of f(x,y) are found by solving the 3 equat
ions (1), (2), (3) above."}}{INP_R 31 0 "> "{TEXT 0 46 "exp3:= so
lve(\{q=0, exp1=0, exp2=0\}, \{x,y,mu\});"}}{OUT_R 32 0 31{DAG :3
n4\`exp3`%2,4=3n3\`y`(3n4\`RootOf`,2+7*3n3\`_Z`j2x0002p12p10i2x00
04j2x0001p18=3n3\`x`+3p9i2x0001=3n3\`mu`+5p9i2x0002p18p18}}{COM_R
 33 0{TEXT 1 0 ""}}{COM_R 34 0{TEXT 1 52 "The quadratic roots are
 real and can be found using:"}}{INP_R 35 0 "> "{TEXT 0 19 "readl
ib(allvalues):"}}{INP_R 36 0 "> "{TEXT 0 33 "allvalues(RootOf(2*_
z^2-4*_z+1));"}}{OUT_R 37 0 36{DAG ,3+5j2x0001p2*3j2x0002/3p2p6p8
+5p2p2p5/3i2x0001p6}}{INP_R 38 0 "> "{TEXT 0 8 "exp4:=\";"}}
{OUT_R 39 0 38{DAG :3n4\`exp4`,3+5j2x0001p6*3j2x0002/3p6pApC+5p6p
6p9/3i2x0001pA}}{COM_R 40 0{TEXT 1 11 "Maximum at:"}}{INP_R 41 0 
"> "{TEXT 0 33 "subs(\{x= -exp4[1],y= exp4[1]\},f):"}}{INP_R 42 0
 "> "{TEXT 0 16 "fmax:= evalf(\");"}}{OUT_R 43 0 42{DAG :3n4\`fma
x`e3j4x001078259018i2x0007}}{COM_R 44 0{TEXT 1 11 "Minimum at "}}
{INP_R 45 0 "> "{TEXT 0 33 "subs(\{x= -exp4[2],y= exp4[2]\},f):"}
}{INP_R 46 0 "> "{TEXT 0 16 "fmin:= evalf(\");"}}{OUT_R 47 0 46
{DAG :3n4\`fmin`e3j4x003174098197i2x0009}}{COM_R 48 0{TEXT 1 0 ""
}}{COM_R 49 0{TEXT 1 306 "Now check this result graphically.  If 
your version of Maple cannot plot implicit functions, then use ei
ther an explicit or parametric expression for f and q. This sheet
 uses the implicit form.  Plot the maximal behaviour of f and the
 circle representing q = 0, which is the unit circle centred at (
-1,1). "}}{INP_R 50 0 "> "{TEXT 0 12 "with(plots):"}}{INP_R 51 0 
"> "{TEXT 0 44 "implicitplot(\{f=fmax,q=0\}, x=-3..3, y=-3..3,"}}
{INP_R 52 0 "> "{TEXT 0 81 "                                     
   axes=NORMAL,title=`CONDITIONAL MAXIMUM`);"}}{INP_R 53 0 "> "
{TEXT 0 45 "implicitplot(\{f=fmin,q=0\}, x=-2..2, y=-2..2, "}}
{INP_R 54 0 "> "{TEXT 0 82 "                                     
   axes=NORMAL, title=`CONDITIONAL MINIMUM`);"}}{COM_R 55 0{TEXT 
1 0 ""}}{COM_R 56 0{TEXT 1 79 "The constrained maxima and minima 
can also be viualised using three dimensions:"}}{INP_R 57 0 "> "
{TEXT 0 50 "plot3d(\{f - fmax,q\}, x=-2..0, y=0..2, axes=BOXED);"
}}{INP_R 58 0 "> "{TEXT 0 50 "plot3d(\{f - fmin,q\}, x=-2..0, y=0
..2, axes=BOXED);"}}{COM_R 59 0{TEXT 1 0 ""}}{COM_R 60 0{TEXT 1 
238 "Note these values are not the maximum or minimumturning valu
es of f(x,y), but the maximum and minimum valuesof f which lie on
 the circle q(x,y).  Note also the the Langrange multiplier mu ne
ed not be evaluated and may remain undetermined."}}{COM_R 61 0
{TEXT 1 0 ""}}{COM_R 62 0{TEXT 1 10 "EXAMPLE 2."}}{COM_R 63 0
{TEXT 1 0 ""}}{COM_R 64 0{TEXT 1 69 "Using the same procedure, ca
lculate the maximum andminimum values of:"}}{COM_R 65 0{TEXT 1 0 
""}}{INP_R 66 0 "> "{TEXT 0 29 "f := 8*x^2 - 12*x*y + 17*y^2;"}}
{OUT_R 67 0 66{DAG :3n3\`f`+7*3n3\`x`j2x0002j2x0008*5p5j2x0001n3\
`y`pDi2x0012*3pFp7j2x0017}}{INP_R 68 0 "> "{TEXT 0 80 "q := x^2 +
 y^2 - 1;                                                        
 #(1)"}}{OUT_R 69 0 68{DAG :3n3\`q`+7*3n3\`x`j2x0002j2x0001*3n3\`
y`p7p9i2x0001p9}}{INP_R 70 0 "> "{TEXT 0 14 "g := f + mu*q;"}}
{OUT_R 71 0 70{DAG :3n3\`g`+9*3n3\`x`j2x0002j2x0008*5p5j2x0001n3\
`y`pDi2x0012*3pFp7j2x0017*5n3\`mu`pD+7p4pDp14pDi2x0001pDpDpD}}
{INP_R 72 0 "> "{TEXT 0 72 "exp1:= Diff(g,x);     exp1:= diff(g,x
);                             #(2)"}}{OUT_R 73 0 72{DAG :3n4\`ex
p1`(3n4\`Diff`,3+9*3n3\`x`j2x0002j2x0008*5pBj2x0001n3\`y`p13i2x00
12*3p15pDj2x0017*5n3\`mu`p13+7pAp13p1Ap13i2x0001p13p13p13pB}}
{OUT_R 74 0 72{DAG :3n4\`exp1`+7n3\`x`j2x0016n3\`y`i2x0012*5n3\`m
u`j2x0001p5p10j2x0002}}{INP_R 75 0 "> "{TEXT 0 73 "exp2:= Diff(g,
y);      exp2:= diff(g,y);                             #(3)"}}
{OUT_R 76 0 75{DAG :3n4\`exp2`(3n4\`Diff`,3+9*3n3\`x`j2x0002j2x00
08*5pBj2x0001n3\`y`p13i2x0012*3p15pDj2x0017*5n3\`mu`p13+7pAp13p1A
p13i2x0001p13p13p13p15}}{OUT_R 77 0 75{DAG :3n4\`exp2`+7n3\`x`i2x
0012n3\`y`j2x0034*5n3\`mu`j2x0001p9p10j2x0002}}{INP_R 78 0 "> "
{TEXT 0 46 "exp4:= solve(\{q=0, exp1=0, exp2=0\}, \{x,y,mu\});"}}
{OUT_R 79 0 78{DAG :3n4\`exp4`,3%2,4=3n3\`mu`i2x0005=3n3\`x`(3n4\
`RootOf`,2+5*3n3\`_Z`j2x0002j2x0005i2x0004j2x0001=3n3\`y`+3pF/3p1
Ep18%2,4=3pD(3p10,2+5p15p1Ai2x0001p1E=3p8i2x0020=3p21+3p2Ci2x0002
}}{COM_R 80 0{TEXT 1 0 ""}}{COM_R 81 0{TEXT 1 78 "You will find i
n this example there are two conditional maxima and two minima."}
}{INP_R 82 0 "> "{TEXT 0 55 "exp4 := allvalues(exp4[1],'d'), allv
alues(exp4[2],'d');"}}{OUT_R 83 0 82{DAG :3n4\`exp4`,5%2,4=3n3\`m
u`i2x0005=3n3\`x`+3*3j2x0005/3j2x0001j2x0002/3p16p11=3n3\`y`+3p10
/3p14p11%2,4p7=3pD+3p10/3i2x0002p11=3p1C+3p10/3i2x0001p11%2,4=3p8
i2x0020=3p1Cp28=3pDp1E%2,4p38=3p1CpF=3pDp30}}{INP_R 84 0 "> "
{TEXT 0 21 "for i from 1 to 4 do;"}}{INP_R 85 0 "> "{TEXT 0 28 " 
    f.i := subs(exp4[i],f);"}}{INP_R 86 0 "> "{TEXT 0 3 "od;"}}
{OUT_R 87 0 86{DAG :3n3\`f1`j2x0005}}{OUT_R 88 0 86{DAG :3n3\`f2`
j2x0005}}{OUT_R 89 0 86{DAG :3n3\`f3`j2x0020}}{OUT_R 90 0 86{DAG 
:3n3\`f4`j2x0020}}{INP_R 91 0 "> "{TEXT 0 55 "fmax := max(f1,f2,f
3,f4); f1: fmin := min(f1,f2,f3,f4);"}}{OUT_R 92 0 91{DAG :3n4\`f
max`j2x0020}}{OUT_R 93 0 91{DAG :3n4\`fmin`j2x0005}}{COM_R 94 0
{TEXT 1 0 ""}}{COM_R 95 0{TEXT 1 48 "Now plot the functions to co
nfirm these answers."}}{INP_R 96 0 "> "{TEXT 0 42 "implicitplot(\
{f=fmax,q=0\},x=-3..3,y=-3..3,"}}{INP_R 97 0 "> "{TEXT 0 73 "    
                           axes=NORMAL, title=`CONDITIONAL MAXIMU
M`);"}}{INP_R 98 0 "> "{TEXT 0 42 "implicitplot(\{f=fmin,q=0\},x=
-2..2,y=-2..2,"}}{INP_R 99 0 "> "{TEXT 0 73 "                    
           axes=NORMAL, title=`CONDITIONAL MINIMUM`);"}}{INP_R 
100 0 "> "{TEXT 0 52 "implicitplot(\{f=fmax,f=fmin,q=0\}, x=-2..2
, y=-2..2, "}}{INP_R 101 0 "> "{TEXT 0 44 "                      
         axes=NORMAL);"}}{INP_R 102 0 "> "{TEXT 0 38 "plot3d(\{f 
- fmax,q\}, x=-1..1, y=-1..1,"}}{INP_R 103 0 "> "{TEXT 0 72 "    
                           axes=BOXED, title=`CONDITIONAL MAXIMUM
`);"}}{INP_R 104 0 "> "{TEXT 0 39 "plot3d(\{f - fmin,q\}, x=-1..1
, y=-1..1, "}}{INP_R 105 0 "> "{TEXT 0 72 "                      
         axes=BOXED, title=`CONDITIONAL MINIMUM`);"}}{INP_R 106 0
 "> "{TEXT 0 0 ""}}}{END}
