Engineering Mathematics Practical Lab 2 (Maple Software) PDF

Title Engineering Mathematics Practical Lab 2 (Maple Software)
Course Engineering Mathematics 120
Institution Curtin University
Pages 5
File Size 160.5 KB
File Type PDF
Total Downloads 108
Total Views 145

Summary

This is the question worksheet used for the practical lab class Engineering Mathematics 120 Lab 2 (Maple Software)....


Description

Engineering Mathematics 1 Laboratory Session 2 Learning outcomes for this session At the end of this session, you will be able to 1. Use Maple for expansion and factorization. 2. Recognize the difference between expressions, equations and functions in a Maple worksheet. 3. Learn how Maple deals with surds. 4. Learn how to plot several functions simultaneously. 5. Use Maple to find limits of functions. Overview 1. Maple specific features: currency of assignments, expressions, equations, functions, reloading old worksheets. 2. Further techniques for algebraic manipulation. 3. Manipulating and plotting more complicated functions.

Important Note: To be consistent across the various laboratories, you should be using the ‘Classic Worksheet’ version of Maple. Even though the standard version of Maple is available, the discussion below may be misleading or confusing if it is used instead of the classic worksheet version. More on Maple As you would have noticed by now, we often use names in a Maple worksheet when we want to describe a quantity, an expression or even an equation. Type in the following for later use: eqn:=y^2-r^2=1; x:=9; z:=u^2+v^2; Allowable names to be used in Maple are any letter followed by zero or more letters, digits and underscores. Spaces are not allowed, so use underscores instead. The only limitations are that we can’t use pre-defined Maple names such as Pi (= the value of π), exp (for the exponential function), sin, cos etc. Also note that Maple is case sensitive, so it will regard ‘z’ and ‘Z’ as two distinct names. Names in Maple are either assigned or unassigned. The ‘:=’, as used above, is used to assign a value, expression or even an equation to a name. Once made, an assignment remains active within a worksheet until it is re-assigned. If you want to unassign the value of a name, the easiest way is as follows > z:='z'; Check what z is in your Maple worksheet before and after this last assignment. In general, name:=’name’; will do the job of unassigning a name. Notice in particular that a simple ‘=’ cannot be used for assignments. Instead, it is reserved for defining equations. This should become clear in the carrying out the following commands: > x:='x'; > eqn:=x=5; > x; Although we entered the equation x=5, this is not the same as assigning the value of 5 to x by x:=5; If you have made multiple assignments to the same name, which one is valid at any one time? Because Maple allows you to go back up a worksheet and re-enter individual command lines, it is not always the last assignment which appears in the sheet! Instead, it is the one corresponding to the most recently entered command line. This 1

can be confusing if you get into the habit of scrolling back and forth in your worksheet frequently and re-enter command lines, so a little care is needed to maintain a tidy worksheet with sequentially entered command lines. Finally, if you saved your worksheet last week and open it up for today’s session, none of the assignments in the sheet will be active anymore. If you want to reactivate them, you need scroll back and re-enter the corresponding command lines. Saving, closing and reopening a worksheet is thus an neat way of clearing all assigned names within a sheet, although the ‘restart’ command we used last week does the same job. In the last session, we used three different fundamental constructs recognized by Maple. These are known as expressions, equations and functions. An expression is any combination of constants and variable names that evaluates to a real (or complex) number if all unassigned names are given real (or complex) values. An equation is a statement of equality involving ‘=’ with the left and right hand sides being expressions. A function is understood in the mathematical sense, i.e. it is a procedure into which an expression can be entered and which will result in a corresponding output which depends on what the function does. The following examples should make this distinction clear. > restart; > f(x):=x^2+2*x-4; Here, we are not defining a function f(x) for Maple, but simply assigning an expression to the name ‘f(x)’! Attempting to evaluate this ‘function’ simply will not work, eg. try > f(2); f(t+1); In this case, Maple regards ‘f(2)’ and ‘f(t+1)’ simply as new variable names which are as yet unassigned. Contrast this with the proper way of defining a function: > f:=x->x^2+2; > f(2); f(t+1); There is an easy way of converting an expression assignment to a function assignment, using the ‘unapply’ command. This is useful if you want to convert a complex expression that may have resulted from another computation into a function. For example, > expr:=(a+b)^5; > expand(%); > subs({a=sin(t),b=cos(t)},%); > f:=%; > f:=unapply(%,t); > evalf(f(3)); has created a fairly complex looking function with very little effort on our part! Simple functions are more easily defined directly, though. Algebra In the first week of lectures, we briefly looked at the tasks of expanding brackets in algebraic expressions. While a single bracket or a pair of brackets can be readily multiplied out by hand, products of multiple brackets are often tedious. We can use Maple for these, as follows. > expand((x+1)^2*(x-1)*(x+4)^3*(x^2+8)); Not surprisingly, Maple is also capable of factorizing some complicated expressions, when it is possible to do so: 2

> factor(%); Notice that the commands work for expressions involving any number of variable names: > expr:=x^2*y*z+x*y^2*z+x*y*z^2; > factor(expr); The ‘normal’ function can be used to combine sums or differences of rational functions: > expr1:=1/(x+4)-2/(x^2-2*x+1); > expr2:=normal(expr1); and ‘numer’ and ‘denom’ will allow us to extract numerators and denominators: > numer(expr2); > denom(expr2); These tools are very useful when analysing and manipulating rational functions. Combinations of Functions When combining several functions algebraically, care must be used to include brackets. Consider the following example. > restart; > f:=x->x^2+3*x; g:=x->sqrt(x^2+5); > f+g(x); does not produce the sum of the two functions as one may have expected, since the ‘f’ without an argument is just the variable name for the function. Instead, we need to enter > (f+g)(x); to produce the true sum of the two functions. An alternative is to simply define the sum to be an entirely new function > h:=f+g; > h(x); Compare the result to the one obtained above. Proceed similarly for products and quotients of functions. The composition of two functions ‘f’ and ‘g’ is indicated by ‘f@g’ or ‘g@f’ and, again, brackets must be used when these are to be evaluated. > (f@g)(x); > (g@f)(x); Note, how in true Maple form, it has simplified the expressions for these composites. Check the validity of the above for yourself or simply use Maple as follows: > f(g(x)); > g(f(x)); Note how this is a simple alternative for defining composites. Many engineering functions are defined in a piecewise manner and Maple has the ‘piecewise’ feature which works as illustrated by the following example: > h:=x->piecewise(x h(1-t); Graphing We had a brief exercise of plotting a function last week. Note that it is also possible to plot multiple functions on the same graph as follows: > plot({h(x),x^3-3*x},x=-5..5); 3

We simply need to enclose the required functions in curly braces as they represent a set of functions. Note how adjusting the range of function values often gives a much clearer picture of the functions involved: > plot({h(x),x^3-3*x},x=-5..5,y=-5..5); Because Maple’s plotting tool is numerically based (i.e. it essentially evaluates the function at many points to produce the graphs), it has difficulties when plotting functions with discontinuities. Since it tries to join up successive points on the graph, it will usually display a (near) vertical line at a discontinuity. Try the following examples > restart; > f:=x->(13*x^2-34*x+25)/(x^2-3*x+2); > g:=x->piecewise(x plot(f(x),x=-4..6,y=-15..20); > plot(g(x),x=-2..2); These vertical lines are not a true part of the graph in each case. If you suspect a discontinuity after plotting a graph, you can add the ‘discont=true’ option to the plot command and Maple will usually pick up its error. > plot(f(x),x=-4..6,y=-15..20,discont=true); > plot(g(x),x=-2..2,discont=true); Finally, note that Maple treats roots of negative numbers in a rather non-intuitive fashion. In particular, it always responds with a complex answer when asked to find the n-th root of a negative number. This is appropriate when looking at an even root, but not when looking at an odd root which should be real and negative. Try calculating the cube root of 27, for example: > z:=(-27)^(1/3); > simplify(z); (Note how the ‘simplify’ command forces Maple to do an exact evaluation as opposed to a decimal evaluation.) While the above does turn out to be a valid cube root of –27, it would have been natural to expect a –3. This is not actually a fault in Maple because it is just being consistent with the normal rules of complex number arithmetic, but we won’t see why until later in the semester. Notice that this also causes difficulties when trying to plot functions involving roots. Consider this example: > h:=x->x^(1/3); > plot(h(x),x=-5..5); Even though we know the cube root of a negative number exists, Maple is refusing to plot it. The way around these difficulties is to use the ‘surd’ command. ‘surd(x,n}’ simply means the real n-th root of x. Try these: > surd(-27,3); > h:=x->surd(x,3); > plot(h(x),x=-5..5); Limits Maple is also able to find a variety of different types of limits of functions as shown by the examples below. > limit((x^3+4*x-5)/(3*x+4*x^3),x=2); > limit((x^3+4*x-5)/(3*x+4*x^3),x=infinity); > limit((x^3+4*x-5)/(3*x+4*x^3),x=-infinity); 4

You will find this useful when investigating more complicated functions in the future. Annotating Your Worksheet Note that Maple provides several ways to add plain text to your worksheet and also a neat way of sectioning parts of the sheet. Text can be added by simply by dragging down the ‘Insert’ option from the menu bar and choosing ‘Text’ (or using Control-T). Once you’ve finished typing, move the cursor to the next line (i.e. outside of the current execution group) and press enter. When solving the exercises to be submitted, the markers will be more favourable to well annotated worksheets which explain what you are doing and comment on the results given by Maple when asked to do so in the exercises. You can also uses annotations if you get stuck to explain what you were attempting to do at that point. Exercises You may work in pairs and learn from one another for these exercises, if you wish. These are merely for practice. The assessment tasks follow in the second hour of the session. 1. Define g(x) be the fifth root function in Maple. Also define the function q(x)=x 2-1. Plot both of these on the same pair of axes. At how many points do these two functions intersect? Determine the x-coordinates of the intersection points (remember the ‘fsolve’ command from the previous session). 2. The Heaviside function, u(t), is of fundamental importance in the analysis of dynamic system response. u(t) is defined to be equal to zero for t...


Similar Free PDFs