For example evaluate the solution at u 1 and t 1 eval

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: , {1 = 1, 3 = 3}] This method can be valuable if your equation has many solutions, or if you are unsure of the number of solutions that a certain command produces. Restricting Solutions You can limit solutions by specifying inequalities with the solve command. > solve({x^2=y^2},{x,y}); 48 • Chapter 3: Finding Solutions {x = −y, y = y }, {y = y, x = y } > solve({x^2=y^2, x<>y},{x,y}); {x = −y, y = y } Consider this system of five equations in five unknowns. > > > > > eqn1 eqn2 eqn3 eqn4 eqn5 := := := := := x+2*y+3*z+4*t+5*u=41: 5*x+5*y+4*z+3*t+2*u=20: 3*y+4*z-8*t+2*u=125: x+y+z+t+u=9: 8*x+4*z+3*t+2*u=11: Solve the system for all variables. > s1 := solve({eqn1,eqn2,eqn3,eqn4,eqn5}, {x,y,z,t,u}); s1 := {x = 2, t = −11, z = −1, y = 3, u = 16} Solving for a Subset of Unknowns You can also solve for a subset of the unknowns. Maple returns the solutions in terms of the other unknowns. > s2 := solve({eqn1,eqn2,eqn3}, { x, y, z}); 527 28 70 59 − 7t − u, z = − − 7 t − u, 13 13 13 13 70 635 + 12 t + u} y= 13 13 s2 := {x = − Exploring Solutions You can explore the parametric solutions found at the end of the previous section. For example, evaluate the solution at u = 1 and t = 1. > eval( s2, {u=1,t=1} ); {x = 861 −220 −646 ,y= ,z= } 13 13 13 Suppose that you require the solutions from solve in a particular order. Since you cannot fix the order of elements in a set, solve does not necessarily return your solutions in the order x, y, z . However, lists do preserve order. Try the following. 3.1 The Maple solve Command > eval( [x,y,z], s2 ); • 49 [− 28 635 70 70 59 527 − 7t − u, + 12 t + u, − − 7 t − u] 13 13 13 13 13 13 This command fixed the order and extracted the right-hand side of the equations. Because the order is fixed, you know the solution for each variable. This capability is particularly useful if you want to plot the solution surface. > plot3d(%, u=0..2, t=0..2, axes=BOXED); –5 –10 –15 –20 –25 50 55 60 65 –58 –56 –54 –52 –50 –48 –46 –44 –42 70 75 80 The unapply Command For convenience, define x = x(u, t), y = y (u, t), and z = z (u, t), that is, convert the solutions to functions. Recall that you can easily select a solution expression for a particular variable using eval. > eval( x, s2 ); − 527 28 − 7t − u 13 13 However, this is an expression for x and not a function. > x(1,1); x(1, 1) To convert the expression to a function, use the unapply command. Provide unapply with the expression and the independent variables. For example, 50 • Chapter 3: Finding Solutions > f := unapply(x^2 + y^2 + 4, x, y); f := (x, y ) → x2 + y 2 + 4 produces the function, f , of x and y that maps (x, y ) to x2 + y 2 + 4. This new function is easy to use. > f(a,b); a2 + b2 + 4 Thus, to make your solution for x a function of both u and t, obtain the expression for x, as above. > eval(x, s2); − 28 527 − 7t − u 13 13 Use unapply to turn it into a function of u and t. > x := unapply(%, u, t); x := (u, t...
View Full Document

Ask a homework question - tutors are online