214 97 1MB
Russian Pages 76 Year 2004
VOLGOGRAD STATE MEDICAL UNIVERSITY DEPARTMENT OF BIOMEDICAL PHYSICS
Denis V. Kovrizhnykh
8 LESSONS IN MAPLE for Medical Students
К вр
8У
К
я
ы
. .
АММ MAPLE
в-
«PEREMENA»
и в
73 30 568 ты: Аки
В.Н., К
С р
ра
.-
.
А.С., -
, .-
, .
,
, . ,
, , .
и А.И., -
.
,
;
-
;
,
-
, , .
-
.
Kovrizhnykh, Denis V. 8 Lessons in Maple for Medical Students. — Volgograd: Peremena, 2004. — 76 p. К вр ы . . 8 2004. 76 .
MAPLE
-
.—
:
,
ISBN 5-88234-612-6 , (
) Maple
. : Maple,
Maple,
Maple,
Maple, ,
,
, , ,
( ),
. . ,
.
. .
,
,
. ISBN 5-88234-612-6 © Denis V. Kovrizhnykh, 2004 2
CONTENTS PREFACE ....................................................................................................................... 5 INTRODUCTION ............................................................................................................. 6 LESSON 1. MAPLE INTERFACE................................................................................... 7 LESSON 2. NUMERICAL CALCULATIONS .................................................................. 9 LESSON 3. SOLVING EQUATIONS ............................................................................ 13 LESSON 4. PLOTTING GRAPHS ................................................................................ 14 LESSON 5. DIFFERENTIAL CALCULUS .................................................................... 16 LESSON 6. INTEGRAL CALCULUS............................................................................ 18 LESSON 7. SOLVING DIFFERENTIAL EQUATIONS.................................................. 20 LESSON 8. ELEMENTARY STATISTICS .................................................................... 22 APPENDIX 1. MAPLE MENU BAR, TOOLBAR AND CONTEXT MENU .................... 26 § 1.1. Maple Menu Bar ........................................................................................... 26 File Menu ......................................................................................................... 26 Edit Menu......................................................................................................... 27 View Menu ....................................................................................................... 30 Insert Menu...................................................................................................... 33 § 1.2. Maple Toollbar ............................................................................................. 34 § 1.3. Maple Context Bar ....................................................................................... 34 Context Bar for 2-D Plots ............................................................................... 34 Context Bar for 3-D Plots ............................................................................... 35 Context Bar for Animations ........................................................................... 35 Context Bar for Maple Input........................................................................... 36 Context Bar for Maple Output........................................................................ 36 Context Bar for Spreadsheets ....................................................................... 36 Context Bar for Text Regions ........................................................................ 37 § 1.4. Maple Right-Click Context Menu................................................................ 37 APPENDIX 2. APPLICATIONS OF NUMERICAL CALCULATIONS ........................... 39 § 2.1. Operator of Approximation......................................................................... 39 § 2.2. Finite and Infinite Sums and Products ...................................................... 40 § 2.3. Operator of Limit ......................................................................................... 42 § 2.4. Operator of Assignment.............................................................................. 44 § 2.5. Solving Simple Problems by Maple ........................................................... 44
3
APPENDIX 3. APPLICATIONS OF SYMBOLIC OPERATIONS WITH EXPRESSIONS47 § 3.1. Solving Problems by Solving Equations ................................................... 47 § 3.2. Solving Systems of Equations ................................................................... 48 § 3.3. Solving Problems by Solving Systems of Equations ............................... 49 § 3.4. Expanding Expressions .............................................................................. 51 § 3.5. Simplifying Expressions ............................................................................. 51 APPENDIX 4. APPLICATIONS OF ‘PLOT’ OPERATOR............................................. 52 § 4.1. Solving Problems by Plotting Graphs ....................................................... 52 § 4.2. Parametric Plots .......................................................................................... 54 § 4.3. Three-Dimensional Plots............................................................................. 55 APPENDIX 5. APPLICATIONS OF DIFFERENTIAL CALCULUS ............................... 57 § 5.1. Plotting Tangent Lines ................................................................................ 57 § 5.2. Solving Problems by Using ‘diff’ Operator................................................ 59 APPENDIX 6. APPLICATIONS OF INTEGRAL CALCULUS....................................... 60 § 6.1. Calculating an Area of a Plane Figure Bounded by Lines ....................... 60 § 6.2. Double Integrals .......................................................................................... 62 § 6.3. Solving problems by using ‘int’ operator .................................................. 63 APPENDIX 7. APPLICATIONS OF SOLVING DIFFERENTIAL EQUATIONS............. 65 § 7.1. Differential Equations with Initial Conditions ........................................... 65 § 7.2. Solving Problems by Differential Equations ............................................. 66 APPENDIX 8. HOW TO USE MAPLE HELP ................................................................ 68 § 8.1. Introduction and New User’s Tour ............................................................. 68 § 8.2. Using Help.................................................................................................... 70 § 8.3. Topic Search and Full Text Search ............................................................ 71 KEY TO THE EXERCISES ........................................................................................... 72 INDEX ........................................................................................................................... 74 REFERENCES .............................................................................................................. 75
4
PREFACE This course is intended for medical students to enlarge the scope of use of mathematics for the purposes of medical research. This course consists of 8 Lessons that allow one to learn the basic abilities of Maple — widely used mathematical software. Generally the Course consists of two parts — the Lessons and Appendices. The Lessons are devoted to the main themes of Higher Mathematics a medical student is supposed to master; the Appendices describe the application of the Lessons’ themes. Every Lesson contains the explanations of the theme it is devoted to, the Examples, Figures that visualize the Examples, the Notes, the Exercises and the Appendices. The Notes point out the important peculiar properties necessary for further Exercises. The Notes are marked off by the lines and background colour. This book allows the teacher to vary the course and the difficulty of the tasks according to the speciality of the students (General Medicine, Paediatrics, Dentistry, Pharmacology, etc.). The Applications may be used both for ordinary study and extra lessons (or self-study). The Applications to the Lessons have the same number as the Lessons: Applications 1.*i refer to Lesson 1, Applications 2.* refer to Lesson 2, and so on. Some paragraphs of the Applications are the reviews of the themes and do not contain Exercises (for instance, § 1.2, § 2.4, and § 8.1). The Lessons should be studied in the given order because some exercises require the student’s competence of previous Lessons. The course is integrated with the course of Higher Mathematics for medical students and is bound up with the course of Biomedical Physics and Chemistry. The exercises may be saved in files (Lesson-by-Lesson) or in the single file on a hard or a floppy disc. This allows the student to use the results of previous Lessons and the teacher to check the results at any convenient time. May be used for self-study.
Acknowledgements The author is thankful to V.N. Akimov, S.V. Borisenok, V.I. Danilchuk, S.Y. Glazov, V.V. Joura, A.S. Kondratyev, I.N. Konovalova, V.A. Krylova, Zh.S. Martinson, O. Petrova, E.O. Pleshakova, A.I. Souryguine, E.S. Verstakov, T.V. Zarubina and D.V. Zavyalov for rendered help. The author would be thankful for sending remarks, comments, advices and corrections to e-mail: [email protected].
i
1.* means the variety 1.1, 1.1, 1.2, 1.3 and so on.
5
INTRODUCTION This book opens a small window to the great world of Maple — a complete mathematical problem-solving environment supporting a wide variety of mathematical operations such as numerical analysis, symbolic algebra, and plotting graphs. Since Mathematics is widely used in scientific research, the use of mathematical software is necessary for every scientist, especially those who are not mathematicians. This Course represents the basic Maple commands according to the Higher Maths course that every medical student should be aware of. The course covers many topics of Maple, including: The Maple Interface, Numerical Calculations, Solving Equations, Differential and Integral Calculus, Plotting Graphs, Differential Equations, and Statistics. The Appendices cover the following topics: Maple Menu, Limits, Solving Systems of Equations, Expanding and Simplifying Expressions, ThreeDimensional and Parametric Plots, Double Integrals, Differential Equations with Initial Conditions, Solving Various Problems by Maple, and Using Maple Help. Besides Mathematics, a lot of physical and some chemical problems are advised to be solved in the Appendices of the book. In the Examples and Exercises, some functions and problems are explained and discussed in several Appendices, so different ways of solving the problems are used. Bold type is used to mark Lessons, Notes, Examples, Figures, Menus, Appendices, and new terms that are ready explained. Italic type is used to mark the link to the picture or paragraph (for example, see Fig. ##) and new terms that are explained in another part of the book. Maple o p e r a t o r s , p a r a m e t e r s , p a c k a g e s (and s u b p a c k a g e s ), and c o m m a n d l i n e s have C o u r i e r N e w bold type. The keys that must be typed are in [square brackets]. Index contains the terms explained in the book and may be used for the search of the required concept.
6
LESSON 1. MAPLE INTERFACE Before starting the Course it’s necessary to learn the Maple interface. The appearance of Maple contains the same sections as most modern software. The following specialized key terms used in the Course describe the main components of Maple interface (see Fig. 1): Worksheet in Maple is a document containing Maple commands, created with this graphical user interface. Worksheet files have an .mws extension. Maple Input is the executable input, usually a command or mathematical expression that Maple evaluates. The input is entered at the command prompt ( > ). By default, Maple input is displayed in red type, with a Courier font. Maple Output is the result of an executed Maple input command. (And therefore sometimes simply called the result.) By default, it is displayed in blue type in standard math notation. Execution Group is a set of Maple input with its corresponding output. It is characterized by a large left square bracket, called a group rangei. Execution groups can also contain descriptive paragraphs.
Fig. 1. Maple interface
To start with, there are several important items you should be aware of: 1. New Maple worksheets begin with a single execution group containing an empty command lineii (also command prompt), as shown in Fig.1. New execution groups can also be created by inserting an execution group (using the Insert menuiii).
i
Group range distinguishes execution group consisting of Maple input and corresponding Maple output (see Fig. 1) ii Command prompt is the line of input of Maple commands. iii See § 1.1 of Appendix 1.
7
2. After opening a worksheet, place the cursor on the first command line using the keyboard or your mouse. 3. By pressing [Enter] key, you also move the cursor to the next command line. Example Place the cursor on the first command line and type “1+1;” (as shown below). Press [Enter] key to view the output: > 1+1;
Note. The semicolon at the end of the command line is obligatory. 4. If you happen to place the cursor elsewhere in a worksheet, place it back on the appropriate command line before pressing [Enter] to continue. Please execute the commands in the order they follow because some computations require results of the previous command lines.
Fig. 2. Menu bar, toolbar and context bar of Maple
5. The worksheets can be also used to explore alternative actions by using the menu bar, toolbar and context menu bar (see Fig. 2). To access a context menu, right-click on a Maple input or result (Maple output). Choose an action from the menu and watch what happens to the resulti. Read Appendix 1 for further information. Exercise Match the expressions from two columns: 1) The document containing Maple commands and results; 2) The line for Maple commands; 3) That is obligatory at the end of the command line; 4) The result of an executed Maple input command; 5) A set of Maple input with its corresponding output; 6) The large square bracket defining Maple input and its output; 7) The rectangular bar displayed at the top of the Maple window; 8) The bar of buttons of the most frequently used menu options; 9) That appearing after right-click on Maple input or output;
i
For more detail see § 1.4 of Appendix 1.
8
a) menu bar; b) group range; c) context menu; d) toolbar; e) Maple worksheet; f) command prompt; g) semicolon; h) execution group; i) Maple output.
LESSON 2. NUMERICAL CALCULATIONS At its most basic level, you can use Maple as a very powerful calculator. A principal strength of Maple is its ability to do exact arithmetic. Fractions and radicals during computation are not converted to their decimal equivalent, thereby avoiding round-off errors. When the use decimal equivalents is required, Maple has a command that approximates the value of the expression in a floating-point formi. Example 1 2 30 30 Consider the expression , which may be typed in the following way: 3 20 > (2^30/3^20)*sqrt(3);
Type the expressionii and press the [Enter] key and view the result: 1073741824 3 3486784401
Example 2 Type the limit of y = x — 7 for x = 3 in the worksheetiii, as shown below: > limit(x-7,x=3);
Type this now and press the [Enter] key (See Fig.3).
Fig. 3. Simple calculations and limits in Maple
So, now from the Examples you know how to calculate an expression and how to find the limit of a function when its argument is equal (approaches) to definite value.
i
See § 2.1. of Appendix 2 for detail of use evalf command for generation an approximation and § 1.4 of Appendix 1 for approximation by mouse right-click. ii See § 1.4 of Appendix 1 for performing Maple input into standard mathematical form. iii The same as y(3).
9
Note. Pay attention to the operators below. sign
name
example
meaning
+
operator of addition
a + b
(a plus b)
—
operator of subtraction
a — b
(a minus b)
*
operator of multiplication
a * b
(a times b)
/
operator of division
a / b
(a over b)
^, **
operators of involution
a ^ b
(a to the bth power)
!
operator of factorial
5!
1×2×3×4×5=120
Pi
3.1415
Pi/2
1.570796327
pii
π
pi/2
π/2
sqrt
square root of
sqrt (x)
square root of x
surd
operator of evolution
surd(x,n)
log
logarithm
log[b](x)
ln
natural logarithm (of base 2.718) ln (x)
exp
the exponential function
exp (x)
ex
exp(1)
the base of the natural logarithm
exp (1)
2.718281828
sin (x)
sine of x
sin
nth root of x, logb x natural logarithm of x
cos
trigonometric
cos (x)
cosine of x
tan
functions
tan (x)
tangent of x
cot (x)
cotangent of x
cot arcsin
inverse
arcsin(x)
arcsine of x
arcos
trigonometric
arccos(x)
arccosine of x
arctan
functions
arctan(x)
arctangent of x
arccot(x)
arccotangent of x
arccot
Note. In the functions of variables (‘square root’ and below in the Table) there must be no symbol between the sign of the operator and the variable in brackets. i
pi means the Greek letter π, Pi gives the value of π = 3.1415.
10
Example 3 Calculate
4
256 .
> surd(256,4); 4
Example 4 Find the value of y = cos (x) for x=0. > limit(cos(x),x=0); 1
Example 5 Find the value of y = tan2 (x) for x = π/3. > limit((tan(x))^2,x=Pi/3);
i
3
Fig. 4 represents the calculations of expressions and limits of the functions at given x. For further detail of use the limit operator see §2.3 of Appendix 2.
Fig. 4. Finding values of functions for given value of variable in Maple
i
Note that tan2 (x) = ( tan (x) )2.
11
Exercises I. Calculate the following expressions: 1.
2π ; 3
7. tan
256 ; 16
3π ; 4
2. 153;
8. cot
3. 10.33.5;
π 9. sin 2 ; i
4. 50.5;
10.
4
π 5. sin ; 2
930.25 ;
11. 5 1024 ;
π 6. cos ; 3
12.
32 ⋅ 12 5 4
26873856
.
II. Find the limit of y for given x: 13. y = 2 x 3 − 3x + 4 14. y = (2 x − 1)(3x 2 − 1) 15. y = 2 sin(2 x) + cos( x) 16. y = arccos(2 x − 1)
for x = −2, x = 0, x = 1 ; for x = −1, x = 2, x = 3 3 , x = 2 2 ; for x = 0, x = π 4 , x = 1, x = 2 ;
for x = 0, x =
1 , x = 1.5 . 2
Put down the results into your copybook. Note. See also Appendix 2 for more detail of numerical calculus.
i
Note that sin2 (x) = sin (x) sin (x) = ( sin (x) )2. See Example 4.
12
LESSON 3. SOLVING EQUATIONS An equation is represented externally using the binary operator “=”. An expression, that is an equation, has two operands, the left-hand-side and the right-hand side. The names “=” and equation are known to the type function. Call a sequence to solve an equation: > solve (eqn,var);
where eqn is an equation, inequality or procedure, var is a variable (unknown to solve for). Example 1 > solve( a*x^2 = 4, x );
Type this now and press the [Enter] key. The solution to a single equation solved for a single unknown (variable) is returned as an expression. Example 2 > solve(f=m*a,a); f m
or > solve(f=m*a,{a}); {a =
f } m
Compare the results of the last Example and of that shown in Figure 5.
Fig. 5. Solving equations in Maple
13
The output from solve in general is a sequence of solutions. When solve is unable to find any solutions, the empty sequence NULL is returned. This means that either there are no solutions, or simply that solve was unable to find the solutions. Exercises Solve the equations and put down the results into your exercise book: 2 2 1. 3 x − 7 x + 4 = 0 ; 6. 3 x − 4 x = 3 2 x −8 ; 2. x 2 + 4 x − 13 = 0 ; 7. 5 x +1.5 = 7 2 x ; 3. x + 1 − 3 = 0 ; 8. 2 sin x = 2 cos x ; 4. x + 5 = x − 1 ; 9. 2 x 4 − x 2 − 5 = 0 ; 5. x + 2 − 2 x − 10 = 1 ; 10. 3x 3 + 13x 2 − 10 x = 0 .
LESSON 4. PLOTTING GRAPHS Command «plot» creates a two-dimensional graph of functions. A typical command of the plot function is > plot(f(x),x=a..b);
where f is a real function in x to be plotted, a..b specifies the horizontal range on which the function is plotted. The call plot(f(x),x=a..b, y=c..d) is also possible and c..d specifies the vertical range on which the function is plotted. Note. Multiple functions can be plotted by placing a set or list of functions in the first argument in square brackets (see the Example 2). Options such as color, thickness and style can be specified for each function by placing a list in the appropriate option argument. Example 1 Plot the graph of the function f(x)=sin(x) for x range of 0 to 2π: > plot(sin(x),x=0..2*Pi);
(see Fig. 6) Example 2 Plot the graph of the functions f1(x)=x2 and f2(x)=4x-4 (f2 is the tangent line to the function f1): > plot([x^2, 4*x-4],x=0..4);
Type this now and press the [Enter] key. 14
Fig. 6. Plotting graphs in Maple
Exercises Plot the graphs of the given functions: 1. y = 2 x − 5, x = (−5, 5) ; 2. y = x 2 + 1, x = (−3, 3) ; 3. y = x 3 , x = (−2, 2) ;
4. y = , x = (−5, 5), y = (−5, 5) ; 5. y =
1 x
1 i , x = (−2, 10) ; x −1 1 6. y = 2 , x = (−5, 5) ; x −1 7. y = sin( x), x = (−7, 7) ;
8. y = cos( x), x − (−7, 7) ; 9. y = arcsin(sin( x)) ; ii 10. y = 3 sin( x) cos(7 x) ; 11. y = 5 sin(2 + sin(5 x)) ; 12. y = x sin( x) .
i
Since the default range of y does not visualize the graph of the function, input the acceptable vertical range for exercises 5 and 6, see exercise 4. ii For exercises 9 – 12 input the real horizontal range.
15
LESSON 5. DIFFERENTIAL CALCULUS One of Maple facilities of symbolic calculations is differentiating functions with respect to their independent variables. To find the derivative of a function with respect to its variable by Maple it’s necessary to call a sequence: > diff (expr,x);
where expr is an algebraic expression of a function, x is an independent variable with respect to the derivative should be found. Example > diff(x^2,x); 2x
The operator diff computes the partial derivative of the expression expr with respect to the independent variables x1, x2, ..., xn, respectively. The most frequent use is the derivative of a function of a single variable diff(f(x),x), computing the derivative of the function f(x) with respect to x. If the derivative cannot be expressed (if the expression is an undefined function), the diff function call itself is returned. The capitalized operator name Diff is the inert diff operator, which simply returns unevaluated and allows to check the correctness of the expression in command prompt. The Maple understands Diff to be equivalent to diff for printing purposes but formats the derivative in black to visually distinguish the inert case. Examples > diff(sin(x),x); cos( x )
> diff(x*sin(cos(x)),x); sin( cos( x ) ) − x cos( cos( x ) ) sin( x )
> diff(x^x,x); xx ( ln( x ) + 1 )
16
> Diff(x^x,x); d x x dx
> diff(tan(x),x); 1 + tan( x ) 2
> Diff(tan(x),x); d tan( x ) dx
Note. The combination of both the operators makes the differentiation demonstrative (See Fig. 7).
Fig. 7. Differentiating functions in Maple
Exercises Find the derivatives of the following functions by using both Diff and diff operators:
1 − ln( x) ; 1 + ln( x) 2. y = x ⋅ sin(ln( x)) ;
1. y =
3. y = sin 2 ( x) ⋅ sin( x 2 ) ; 4x + 2 ; 3x 4 5. y = 7 2 tan(5 x) ;
4. y =
9
5
6. y = e − x ln( x) ; 2
7. y = ln
1 + x3 ; 1 − x3
π
8. y = 2 cos( − 3x) ; 6
e ; 9. y = cos(2 x) 1 ; 10. y = 3 x+ x 3x
17
x 11. y = 5 sin 3 ;
3
12. y = x ⋅ x 6 − 8 ; 5
3
13. y = ln 2 (3 ( x 2 + 3) 5 ) .
LESSON 6. INTEGRAL CALCULUS The function int computes an indefinite integral (the antiderivative) of the expression expr with respect to the variable x: > int(expr,x);
Example 1 > int(sin(x),x); −cos( x )
Note that no constant of integration appears in the result. Definite integration is performed if the second argument is of the form x=a..b where a and b are the endpoints of the interval of integration: > int(expr,x=a..b);
Example 2 > int(sin(x),x=0..Pi); 2
The capitalized operator name Int is the inert version of the int operator, which simply returns unevaluated: > Int(function,x); ⌠function d x ⌡
> Int(function,x=a..b); ⌠ function d x ⌡a b
Example 3 > Int(sin(x),x); ⌠sin( x ) d x ⌡
18
Example 4 > Int(sin(x),x=0..Pi);
π
⌠ sin( x ) d x ⌡0
The combination of both the operators makes the integration demonstrative: > Int(ln(x),x)=int(ln(x),x); ⌠ln( x ) d x = x ln( x ) − x ⌡
Fig. 8. Integral calculus in Maple
Exercises 1. ∫ (2 + x) 3 dx ;
2. ∫ e 2 cos( x ) sin x dx ; 3.
∫
∫
x dx 5
x +1 3
x−5
;
6. ∫ 2 x x 2 + 1 dx ;
∫ 4
8.
1+ x
∫
x
1
11.
1
9.
4
∫x
e3
10.
1
2
dx ;
12.
dx
1 + ln x
19
;
dx
∫1+ x 2
5
x (1 + x ) dx .
9
∫ 3 + 4x ;
3
2
4
2
dx ; x 2 − 10 x (1 − x) 2 dx ; 5. ∫ x x
4.
cos( x ) dx 7. ∫ ; 4 π sin ( x ) π
1
2
2
x
2
dx .
LESSON 7. SOLVING DIFFERENTIAL EQUATIONS Differential equation is an equation involving function y of variable xi, the variable x and the derivative of the function with respect to x. Note that the derivative of the function y(x) with respect to x is defined in Maple as diff (y(x),x).
To solve a differential equation in Maple (to find the function y(x)) it’s necessary to call one of the following sequences: > dsolve (ODE,y(x)); > dsolve({ODE,ICs},y(x));
where dsolve is the operator of solving differential equations, ODE is an ordinary differential equation, y(x) is any indeterminate function of one variable, and ICs initial conditionsii. The solution of differential equation is function y(x). Example 1 Solve the differential equation
y' = sin x
y.
Since y ′ is the derivative of y with respect to x (see the Note above), type the following expression in Maple command prompt: > dsolve(diff(y(x),x)/sin(x)=sqrt(y(x)),y(x)); 1 y( x ) + cos( x ) − _C1 = 0 2
where _C1, _C2, … , _Cn are the undefined constants. See §7.1 for solving ODE with initial conditions. The capitalized operator Dsolve is the inert version of the dsolve operator, which simply returns unevaluated and allows to check the correctness of the expression in command prompt. Example 1.1 > Dsolve(diff(y(x),x)/sin(x)=sqrt(y(x)),y(x)); d y( x ) d x Dsolve = y( x ) , y( x ) sin( x ) i ii
Function y of variable x is usually indicated as y(x). See § 7.1 of Appendix 7 for detail of solving differential equations with initial conditions.
20
Example 2 Solve the differential equation y ′ − y 2 + y = 0 . > dsolve(diff(y(x),x)-y(x)^2+(y(x))=0,y(x)); y( x ) =
1 1 + e x _C1
Fig. 9. Solving differential equations in Maple
Exercises Solve the differential equations: 1. y ' =
4. y ' sin 2 x = 3 y ;
y ; 1 + x2
5. y ' y 2 (1 + e x ) = e x ;
2. y '⋅ tan x = y ;
6. y ' =
1 − 2x ; 3. yy' = y
21
x . y2
LESSON 8. ELEMENTARY STATISTICS To access the functions in the stats package by their short names, use the with command: > with(stats);
The stats package supports a range of useful probability distributions, including normal, chi-squared, student t, F, and exponential. You can perform simple statistical operations such as calculating the mean, median, variance, and standard deviation of a data set. To access the functions in the describe subpackage (that allows you to compute the mean, median, variance, and standard deviation) by their short names, execute the with(describe) command: > with(describe);
As an example, let us consider the following data set. Notice that the data is enclosed in square brackets [ ] to make it a list (an ordered sequence of expressions): > data:=[1.1,5.8,3.4,4.2,3.9,5,0.9,6.2];
Note. The “:=” operator assigns the data set to the given word («data» in the sample command). Any word that is not the Maple operator may be used for assigning data setsi. The function mean of the package stats computes the arithmetic mean of the given data. The mean is defined to be the ratio of the sum of the data items (each multiplied by its weight) to the total weight: > mean(data); 3.812500000
The function median of the package stats finds the item in data that corresponds to the middle (central) value in a set of observations. If the requested median falls between entries, it is interpolated. > median(data); 4.050000000
i
See § 2.4 of Appendix 2 for more detail of use the operator of assignment.
22
The function standarddeviation of the package stats computes the standard deviation of the given data. The standard deviation is defined to be the square root of the median. > standarddeviation(data); 1.844883126
Well, now you know how to compute the mean, the median, the variancei, and the standard deviation of the previously entered data after getting access the function in the stats package and in the describe subpackage as shown in Fig. 10.
Fig. 10. Statistics in Maple
The stats package includes a statplots subpackage, that has powerful graphing commands for creating plots that are specific to statistical operations. To access the functions in the statplots subpackage by their short names, execute the with(statplots) command: > with(statplots);
i
Difference of variations; the variance is defined to be the square of the standard deviation.
23
The function histogram of the package stats plots a bar graph for one or more statistical lists. The command histogram(data) will tally the data in data1 into bars of equal area. Classes (ranges) contained in data are plotted as boxes proportional to their weight. > histogram(data);
When more than one statistical list is specified, as in i histogram(data1,data2,...), a 3-dimensional plot is created . One histogram is created for each data set, and they are plotted on the same graph. By default, a probability histogram will be produced: the total area of the bars will be 1. This can be changed by using the area parameter; area=10 will give a histogram with the bars having a total area of 10. The parameter numbars= allows the user to specify how many divisions the data should be broken up into. If the data is spread uniformly, then numbars=y should produce a histogram with y columns: > histogram(data,numbars=5);
The parameter color= allows the user to change the colour of the histogram: > histogram(data,color=yellow);
Note. If the parameter color is missing the default colour is used. Example The following command lines generate a scatter plot with additional graphic elements to aid in data interpretation: > data:=[1.1,5.8,3.4,4.2,3.9,5,0.9,6.2]; > with(statplots); > histogram(data,color=green);
The result is shown in Fig. 11.
i
For detail of 3-D plots see § 4.3.
24
Fig. 11. Histogram in Maple
Exercises Determine the mean, median, variance, and standard deviation and plot histogram for these data sets: 1. The blood pressure of 30 patients is: 151, 166, 133, 155, 179, 148, 143, 128, 138, 172, 163, 157, 158, 136, 169, 153, 142, 147, 134, 164, 167, 131, 152, 145, 176, 122, 149, 154, 161, 156. 2. The heights (in cm) of 30 boys of 2 years age are: 92, 91, 96, 93, 97, 93, 91, 92, 90, 97, 94, 95, 92, 98, 96, 90, 95, 93, 94, 89, 91, 89, 96, 94, 94, 92, 93, 95, 87, 94.
25
APPENDIX 1. MAPLE MENU BAR, TOOLBAR AND CONTEXT MENU § 1.1. Maple Menu Bar Maple has menu bar containing File, Edit, View, Insert, Format, Spreadsheet, Window, Help. Available menus appear on the menu bar. The menus that are available will vary depending on whether a worksheet is closed or open and, if a worksheet is open, where the cursor is placed in that worksheet. File Menu
The File menu contains a collection of commands that you can perform on Maple worksheets: New, Open, Open URL, Save, Save As, Export As, Send, Close, Print, Print Preview, Print Setup, Preferences, Exit.
Menu New opens a new untitled worksheet on starting Maple. You can also create a new worksheet while existing worksheets are open. Menu Open opens an existing worksheet to modify the content or to change its appearance. Menu Open URL, From within Maple, opens a web page from a web server in a browser, or opens a worksheet from a web server in Maple. Before you can open a URL, you must have a browser selected in Maple. Menu Save resaves the current worksheet under its current filename, or save a new worksheet under a specified name. Menu Save As saves an existing worksheet in a different location, with a different name, or as a different file type, or save a new worksheet. Menu Export As exports a worksheet in another format to view it in a Web browser or in another application. Fig. 12. File menu Menu Send sends the current worksheet as an email attachment. Menu Close closes a worksheet on finishing the user’s work. Menu Print prints the active worksheet. Hidden content will not be printed. Menu Print Preview displays the worksheet as it would be printed. Menu Print Setup sets up the page format to use for printing the active worksheet or help page. Menu Preferences customizes your Maple preferences for your current session or for the current session and future sessions. Menu Exit closes Maple when the user has made changes to the worksheet since the last time you saved it; you are prompted to save the changes. Choose Yes, No, or Cancel.
26
Exercise 1 a) Start Maple by double-click on Maple desktop shortcut. b) Save the current worksheet [Untitled (1)] as Student.mws by using Save or Save As commands of File menu. If you have made changes to the worksheet since the last time you saved it, you are prompted to save the changes. Choose Yes, No, or Cancel. c) Restart Maple (exit Maple by using Exit command of File menu or by left-click on the right upper chest). d) Open the last worksheet by using Open command of File menu or by choosing the corresponding filename above the Exit command of File menu (see ‘Lissajous.mws’ and ‘BAP.mws’ in Fig.12). Edit Menu
The Edit menu contains commands for making changes to the contents of a Maple worksheet or for executing a worksheet: Undo, Redo, Cut, Copy, Copy as Maple Text, Paste, Paste Maple Text, Delete Paragraph, Select All, Find, Spellcheck, Hyperlinks, Object, Unit Converter, Complete Command, Entry Mode, Split or Join, Execute, Remove Output.
Menu Undo reverses your last action if you make a mistake or change your mind. Menu Redo reverses the last undone action if you have used the Undo feature. Menu Cut removes the selected expression, or selected part of an expression. Menu Copy as Maple Text copies input, output, and text in the worksheet as Maple text to retain its structure at the pasted location. Menu Paste inserts an expression, or part of an expression, to another location on the worksheet (to the position of insertion point). If you Paste a selection that was copied as Maple text, Maple Fig. 13. The Edit menu does not retain the original structure. To retain the original structure, you must use Paste Maple. You can also Paste the selection into Microsoft(R) Word 2000. The default format is .rtf (rich text format). Menu Paste Maple Text keeps the structure of input and text that was copied as Maple Text, when pasting it into the worksheet as Maple Text (see Copy as Maple Text). Menu Delete Paragraph deletes the paragraph the cursor is placed in. Menu Select All selects all of the contents of the active worksheet. Menu Find searches for and replaces text and input in the active worksheet.
27
Note: if you type "problem" then it will find "problem" but not "Problem" or "PROBLEM". To search forward through the document, click Next, to search backward, click Previous. In the Replace box, type what you want as a replacement for what you typed in the Find box. Click Change to change the current occurrence or Change All to change all occurrences within the current worksheet. To close the dialog box click Cancel (see Fig. 14). The Spellcheck utility examines all Fig. 14. Find window text regions of your worksheet for potential spelling mistakes, that is, where the worksheet is defined to be text. It does not check input, output, or text in execution groups. Menu Hyperlinks allows you to edit the target for hyperlinks within a worksheet, either individually or in a batch. Call the Hyperlink Editor dialog box (choose Hyperlinks From the Edit menu). In the Link Type box, choose All to list all hyperlinks in the worksheet; choose a specific type to list a subset of the hyperlinks. Editing will merely affect selected hyperlinks (to select all entries in the link list, click Select All Links). In the Replace box, enter the pattern to replace and click Change Links to process the search and replace. Click OK. Menu Unit Converter performs unit conversions in a worksheet. Call The Unit Converter dialog box (select Unit Converter from the Edit menu), in the Value box, enter the numerical value to be converted, in the Dimension box, choose the conversion dimension — the type of Fig. 15. Unit Converter window measurable quantity (length, time, speed, force, electric charge, and many others). In the From box, choose the unit to convert from, and in the To box, choose the unit to convert to; click Insert to insert the execution group containing the corresponding Maple command. The Unit Converter dialog box closes. Note: Thermodynamic temperature conversions are for temperature intervals not absolute temperatures. For example, 1 degree Celsius is converted to 1 Kelvin not 274.15 Kelvin. For conversions of absolute temperatures, use the convert/temperature function. 28
Menu Entry Mode toggle between entering in nonexecutable Standard Math notation mode and entering in text mode. A check mark next to Entry Mode indicates the entry mode is Standard Math. If there is no check mark, the entry mode is assumed to be text. Menu Remove Output deletes Maple output from selected execution groups or from the entire worksheet. Select the execution groups containing the Maple output you want to remove. Choose Remove Output from the Edit menu, and then From Selection to remove Maple output from selected execution groups in your worksheet, or then From Worksheet to remove Maple output from all of the execution groups in your worksheet. Exercise 2 a) Retype the command line for the second function from the Example 3 (see Lesson 1) and press the [Enter] key; b) select the command line by using mouse or otherwisei; c) copy the selected expression by using Copy command of Edit menu; d) place the cursor to the new execution group and insert the copied expression by using Paste command of Edit menu; e) replace π/3 with π/6 and press the [Enter] key; f) copy the value of tan2(π/6) to your copybook; g) cancel the last operationii by using Undo result command of Edit menu; h) cancel the replacing of π/3 with π/6 by using Undo Typing command of Edit menu; i) replace π/3 with π/4 and press the [Enter] key; j) copy the value of tan2(π/4) to your copybook. Exercise 3iii Convert the following units by using Unit Converter option of Edit menu and copy the results into your copybook: a) 356 days to seconds; b) frequency of a rotor in Hz that makes 800 revolutions per minuteiv; c) 20 degrees Celsius to degrees Fahrenheit; d) 720 millimeters mercury to Pascal; e) 1324 square feet to square meter; f) 93.642 pound per cubic foot to kilogram per cubic meter; g) 123 miles per hour to meters per second and then to kilometres per hour.
i
To select an expression put the cursor to the beginning or to the end of the command prompt and, keeping Shift key pressed, push Left or Right key until the necessary expression is selected. ii The operation of calculation. iii For Maple 8 only. iv For approximation of the result see §1.4 of Appendix 1 and §2.1 of Appendix 2.
29
View Menu
The View menu contains commands that manipulate the appearance of worksheet contents and the Maple session control bars: Toolbar, Context Bar, Status Bar, Palettes, Zoom Factor, Bookmarks, Back, Forward, Hide Content, Show Invisible Characters, Show Section Ranges, Show Group Ranges, Show Object Type, Expand All Sections, Collapse All Sections (see Fig. 16).
The toolbar is the area of the Maple window that contains buttons for performing common tasks (see Fig. 2). The toolbar can be visible or hidden. From the View menu, choose Toolbar. If there is a check mark next to Toolbar in the menu, then the toolbar is visible (see Figures 16, 17, 21). For more detail of Toolbar see § 1.2 (page 34). The Context Bar is the area of the Maple window that contains buttons for performing Fig. 16. View menu common tasks. The available buttons change as the cursor location or current selection in the worksheet changes. You can toggle between having the context bar visible and having it hidden. From the View menu, choose Context Bar. A check mark next to Context Bar indicates that the context bar is displayed (see Figures 16, 17, 21). For more detail see § 1.3 of Appendix 1. The Status Bar is the bar at the bottom of the Maple window (see Fig. 2). It displays diagnostic messages, menu item help, and system information. You can toggle between having the status bar visible and having it hidden. From the View menu, choose Status Bar. A check mark next to Status Bar in the menu indicates that the status bar is displayed (see Figures 16, 17, 21). A palette is a collection of buttons representing predefined symbols, expressions, operators, Matrices, or Vectors. By clicking on the buttons on the palettes, you can build or edit mathematical expressions without having to remember the Maple command syntax. Maple comes with four palettes (Expression Palette, Matrix Palette, Vector Palette, and Symbol Palette) for Fig. 17. Palettes menu building or editing mathematical expressions without having to
30
remember the Maple command syntax. You can toggle between having the palettes visible and having them hidden. Showing or hiding palettes can be done individually or for all palettes at once. Choose Palettes from the View menu, and select the palette name to display or hide a particular palette. A check mark next to the palette name indicates that the palette is visible (see Fig. 17). To display all palettes, select Show All Palettes. A check mark appears next to each palette name and Show All Palettes becomes disabled. To hide all palettes, select Hide All Palettes. The check mark disappears from beside each palette name and Hide All Palettes becomes disabled. Example Type the expression
sin( x) + cos( x) . ln( x)
First, display the Expression Palette: choose Palettes from the View menu, and then choose Expression Palette — and it becomes visible. Then press the division button of the Expression Palette and Maple notation of division expression appears (see Fig. 18). The numerator expression is selected (visualization by inversed colours), and now press Sine button of the Expression Palette. The expression of Sine operator appears (see Fig. 19), to complete the expression sin(x) press [x] key.
Fig. 18. Typing division expression by using Expression Palette
Next, press [right] key to move the cursor to the end of the Sine expression and type ‘+’. Now press the Cosine button of the Expression Palette (next to Sine button of the Expression Palette see Fig. 19), then type x. Last, press the [Tab] key to move the cursor to the position of denominator, and press the Natural logarithm button of the Expression Palette; type x and press the [Enter] key — the resultant expression will be displayed as Maple output (see Fig. 20).
31
Fig. 19. Typing Sine expression by using Expression Palette
Fig. 20. The result of typing the expression
Use the Zoom Factor feature to make the display of your worksheet larger or smaller. Choose Zoom Factor from the View menu. A check mark indicates the current magnification (see Fig.18). You may select the desired magnification by using corresponding menu command or by using hotkeys: Ctrl + 0 (50%) to Ctrl + 6 (400%). As you jump to hyperlink destinations, a history of the hyperlinks is maintained. To go back through the history, choose Back from the View menu. Choose Forward from View menu to move forward through the history if you have already gone Back (Back and Forward menus are both inactive in Fig. 21).
Fig. 21. Zoom Factor menu
32
Insert Menu
The Insert menu contains commands to insert text and Maple objects into an active Maple worksheet: Text, Standard Math, Maple Input, Standard Math Input, Execution Group, Plot, Spreadsheet, Paragraph, Section, Subsection, Hyperlink, Object, Page Break.
Text menu inserts text into your Maple worksheet. Text can include comments that help explain your steps more effectively. Standard Math notation is displayed in a format similar in appearance to that found in a textbook. It is not necessarily executable. Choose Standard Math from the Insert menu. Type the expression, using the edit field for Fig. 22. Insert menu editing, if necessary and press the [Enter] key. The output will be displayed in nonexecutable Standard Math notation. Maple input is executable Maple notation, usually a mathematical expression that Maple can evaluate. Standard Math Input is executable. An execution group is a grouping of Maple input with its corresponding Maple output. When inserting an execution group, Maple also inserts a command prompti “[>”. Maple commands entered at this prompt are recognized as Maple input and can be executed. Exercise 4 1. Put the check mark near Toolbar, Context Bar and Status Bar of the View menu. Observe the change. Make all the Bars be displayed. 2. Display the Expression Palette of View menu and type the following expressions by using the Palette: i. sin( x ) + cos( x ) ; ii. cos( x) ⋅ ln( x) iii. sin(ln(x)) ; iv. esin(x); v.
sin( x) − cos( x) . sin( x) + cos( x)
3. Hide the Expression Palette by putting off the check mark in the corresponding line of View menu and copy the expressions into your copybook.
i
See Introduction and Lesson 1, pages 5,6.
33
§ 1.2. Maple Toollbar The following is a list of the buttons on the worksheet toolbar Create a new worksheet. Open an existing worksheet. Open a specified URL. Save the active worksheet. Print the active worksheet. Cut the selection to the clipboard. Copy the selection to the clipboard. Paste the clipboard contents into the current worksheet. Undo the last operation. Redo the previously undone operation. Insert nonexecutable Standard Math in a text region. Insert text at the cursor. Insert a new execution group after the cursor. Remove the section enclosing the selection. Enclose the selection in a section or subsection. Go backward in the hyperlink history. Go forward in the hyperlink history. Cancel the computation in progress. Set the zoom magnification to 100%. Set the zoom magnification to 150%. Set the zoom magnification to 200%. Toggle the display of nonprinting characters. Resize the active window to fill the available space. Restart Maple.
§ 1.3. Maple Context Bar Context Bar for 2-D Plots
The following are descriptions of the context bar boxes and buttons for 2-D plots Displays the plot coordinates of the selected point. Changes the curve style to Line. Changes the curve style to Point. Changes the curve style to Patch. 34
Changes the curve style to Patch w/o grid. Changes the axes style to Boxed. Changes the axes style to Framed. Changes the axes style to Normal. Changes the axes style to None. Toggles projection between Constrained and Unconstrained.
Context Bar for 3-D Plots
The following are descriptions of the context bar boxes and buttons for 3-D plots Displays the angle for theta. Edit the number in this box to change the angle. Displays the angle for phi. Edit the number in this box to change the angle. Change the curve or surface style to Patch. Change the curve or surface style to Patch w/o grid. Change the curve or surface style to Patch and contour. Change the curve or surface style to Wireframe. Change the curve or surface style to Contour. Change the curve or surface style to Hidden line. Change the curve or surface style to Point. Change the axes style to Boxed. Change the axes style to Framed. Change the axes style to Normal. Change the axes style to None. Toggle the projection between Constrained and Unconstrained. Context Bar for Animations
The following are descriptions of the context bar boxes and buttons for animations Displays the 2-D plot coordinates of the selected point. Displays the angle for theta in a 3-D plot. Edit the number in this box to change the angle. Displays the angle for phi in a 3-D plot. Edit the number in this box to change the angle. Stop the animation. 35
Play the selected animation. View the next frame in the animation. Set the animation to play forward. Set the animation to play backwards. Set the animation to play at a slower speed. Set the animation to play at a faster speed. Set the animation to run for one cycle. Set the animation to run continuously.
Context Bar for Maple Input
The following context bar buttons are available when the cursor is in Maple input Toggle the input display between Standard Math and Maple notation. Toggle the expression type between executable and nonexecutable. Correct the syntax of the expression. Execute the current expression. Execute the worksheet.
Context Bar for Maple Output
Below are descriptions of the context bar buttons available when the cursor is in Maple output Toggle the display between Standard Math and Maple notation. Toggle the expression type between executable and nonexecutable. Execute the current expression. Execute the worksheet. Replace all occurrences of the selection with the contents of the edit field. Apply the changes to the current command. Cancel the current changes to the command. Context Bar for Spreadsheets
The following are descriptions for each of the context bar buttons available when the cursor is in a Maple spreadsheet 36
Fill selected row or column. Evaluate all stale cells in the spreadsheet. Apply the changes to the cell and evaluate it. Restore input to the previous value. Context Bar for Text Regions
The following are descriptions for the lists and buttons that are available on the context bar when the cursor resides in a text region Displays the text style. Change the text style by selecting the text then selecting a text style from this list. Displays text font. Change the text font by selecting the text then selecting a text font from this list. Displays text point size. Change the text point size by selecting the text then selecting a size from this list. Bold the selected text. Italicise the selected text. Underline the selected text. Align the text on the left side. Centre the text. Align the text on the right side.
§ 1.4. Maple Right-Click Context Menu Right-click menu represents the context Maple menu that makes the user’s management of Maple operations demonstrative and comfortable. Example 1 Right-click the mouse when the pointer is near the command prompt – Maple Input (see Example 5 of Lesson 1), the context menu appears (see Fig. 23). In this example Standard Math option displays the Maple Input in the form that allows to check the correctness of the Input expression. See also Context Bar for Maple Input (page 36).
37
Fig. 23. Standard Math and right-click menu
Example 2 Right-click the mouse when the pointer is near the result – Maple Output, — another context menu appears (see Fig. 24). In this example we consider the approximation: it’s necessary to choose the number of digits of the result of approximation, 5-digit approximation is shown in Fig. 24. See also § 2.1.
Fig. 24. Approximation in Maple
38
APPENDIX 2. APPLICATIONS OF NUMERICAL CALCULATIONS § 2.1. Operator of Approximation Maple always does exact computations (see Lesson 2); it may be also commanded to approximate the result. The evalf function evaluates approximations to floating-point numbers, expressions (or subexpressions) involving constants such as Pi, exp(1), gamma, and functions such as exp, ln, sin, cos, arctan, etc. The accuracy of the result is determined by the value of the environment variable digits. By default the results will be computed using 10-digit floating-point arithmetic, since the initial value of digits is 10: evalf[n](expr);
or evalf(expr, n);
where expr is any expression, n is an (optional) integer; specifies number of digits. The parameter n, that may be given either as an index on the procedure name evalf[n](expr) or as a second argument evalf(expr, n), sets the value of digits for the duration of the computation. Most of Maple's initially known mathematics functions will automatically invoke their corresponding evalf subfunction if they are passed a floating-point argument. Examples > evalf(Pi); 3.141592654
> evalf(sqrt(2)); 1.414213562
> evalf(cos(Pi/6)); 0.8660254040
Note. You may call evalf function just after calculation you wish to approximate: > int(exp(x^3),x=0..1);
⌠ ( x3 ) e dx ⌡ 1
0
> evalf(%); 1.341904418
39
Exercises Calculate and approximate the result due to the accuracy determined by given n: 1. ln(3), n = 5 ; 5. e 2 , n = 10 ; π 4
2. sin 3 , n = 5 ;
3. 4.
6.
π tan , n = 5 ; 6 5 − 3, n = 5 ;
7.
3
e 5 , n = 10 ;
2π
, n = 10 ;
8. π 2 , n = 10 ; 9. log 2 3, n = 5 . 5
§ 2.2. Finite and Infinite Sums and Products
Call one of the following sequences with sum or product command to calculate a sum or a product by Maple: >sum(f, k=m..n); >product(f, k=m..n);
where f is the expression of a function; k is a name, summation index; m and n are integers or arbitrary expressions. Maple calculates both finite and infinite sums. Example 1
∑1+ i 10
Consider the finite sum
i =1
1+ i 4
. You calculate its value as follows:
> sum((1+i)/(1+i^4),i=1..10); 51508056727594732913722 40626648938819200088497
Example 2
Consider the infinite sum
∑k ∞
1
k =1
2
. To calculate its value, enter:
> sum(1/k^2,k=1..infinity); π2 6
Example 3
i 2 + 3i − 11 , enter the following command: ∏ i+3 i =0 10
To evaluate the finite product
> product(((i^2+3*i-11)/(i+3)),i=0..10); -7781706512657 40435200
40
The capitalized operator names Sum and Product are the inert sum and product operators, which simply return unevaluated (see Fig. 25).
Fig. 25. Sums and products in Maple
Exercises I. Calculate the following sums: 1 ∑ 2 ; x =1 x
1.
5
∑y
1.
4
2. 3.
∑ j =0
;
2.
∑m
7.
m =1 ∞
;
x2 +1 4. ∏ ; x =0 x + 1 5 m ; 5. ∏ 2 m=2 m − 1 7 j 2 −1 6. ∏ ; j =2 j + 3
1 2
k =3
k
5
;
∑ (−1) n =1
∏k
;
5
ei 4. ∑ ; i =1 i ∞ 1 5. ∑ ; k =0 k! 6.
y =1
i2 3. ∏ ; i =1 (i + 1)
j2 ; j +1
7
∞
2
5
y
y =1 10
∏y
II. Calculate the following products:
10
n2 + n +1 . 7. ∏ n +1 n =0 3
n
. 41
§ 2.3. Operator of Limit
The limit(y, x=a, dir) function attempts to compute the limiting value of y as x approaches a, where y is an algebraic expression, x – a variable, a an algebraic expression, limit point, possibly infinity, or –infinity, dir - (optional) symbol; direction chosen from: left, right, real, or complex. Example 1 > limit(sin(x)/x, x=0); 1
> limit(exp(x), x=-infinity); 0
If dir is left or right, the limit is a directional limit, taken from the left or right, respectively. If dir is real, the limit point infinity denotes both positive and negative infinity, and the limit is done bidirectionally. If dir is not specified, the limit is the real bidirectional limit, except in the case where the limit point is infinity or -infinity, in that case the limit is from the left to infinity and from the right to -infinity. If Maple cannot find a closed form for the limit, the function calling sequence is returned. Example 2 > limit(1/x, x=0, right);
∞
> limit(1/x, x=0, left);
−∞
> limit(1/x, x=0, real); undefined
> limit(1/x, x=infinity, real); 0
The capitalized function name Limit is the inert limit function, which returns unevaluated. It is printed in black so that it is easily distinguished from a returned limit calling sequence. Note: Since Limit does not try to evaluate or check the existence of the limit of the expression, it can lead to incorrect transformations. Therefore, the use of both the operators Limit and limit is more reliable (see Fig. 26).
42
Fig. 26. Limits of functions in Maple
Exercises Find the following limits: x 1. lim ; x→0 sin( x ) tan( x ) − sin( x) ; 2. lim x →0 x3 2 cos( x) − 1 3. limπ ; 1 − tan 2 ( x) x→
x x cos − sin 2 2 4. limπ ; cos( x) x→ 2
5. xlim →1+
4
43
1 . x −1
§ 2.4. Operator of Assignment
The assignment operator “:=” assigns to the lhs (left-hand side) the value of rhs (right-hand side): >lhs := rhs;
The left-hand side of the assignment operator must evaluate to a name, a function call, or an expression sequence of names or function calls. First, the left-hand side is evaluated to a name. Second, the right-hand side is evaluated as an expression. Finally, the assignment is performed. The value of the assignment statement is the right-hand side. If the left-hand side is a sequence of names, the right-hand side must evaluate to a sequence of expressions with the same number of components as the left-hand side. The assignments are then performed simultaneously on each pair of name and expression. Examples > i := 1; i := 1
> i; 1
Note. The application of the assignment operator is described in § 2.5. § 2.5. Solving Simple Problems by Maple
To solve a problem by Maple it’s necessary to divide the solving into several steps that are mathematical actions: the first step is the symbolic defining of the values used in the problem, and the second is the input of the expression for the calculation of the result. Example Solve the problem: Calculate time necessary for a particle of dust to fall from the ceiling 3 m high to the floor by using Stokes’ law. Consider the particle as a sphere 1 µm diameter, the density of dust ρd = 2.5 g/cm3; the density of air is ρa = 1.29 kg/m3, and its viscosity is η = 18.1 µPa⋅s. Solution First, assign the height h: > h:=3; 44
h := 3
the diameter of the dust particle d: > d:=0.000001; d := 0.1 10 -5
the viscosity of air η (eta): > eta:=0.0000181;
η := 0.0000181
the densities of dust ρ1 (rho1) and air ρ2 (rho2): > rho1:=2500;i
ρ1 := 2500
> rho2:=1.29;
ρ2 := 1.29
the gravity acceleration g: > g:=9.8; g := 9.8
Then, since the movement of the dust particle is considered to be uniform (the Brownian movement is neglected and the air is considered to be motionless), time t
may be calculated by using the formula t =
18 h η h ii : = 2 v d g (ρ1 − ρ 2 )
> t:=(18*h*eta)/(d^2*g*(rho1-rho2)); t := 39914.47343
Last, since time t is calculated in seconds, it’s possible to calculate time T in minutes by dividing t by 60 (or in hours by dividing t by 3600): > T:=t/60; T := 664.9051402
The use of Text and Maple Input options of Insert menuiii allows to make notes for every assignment and calculation (see Fig. 27). i
See § 1.1 of Appendix 1 (page 28) for detail of use the Unit Converter.
ii
iii
2 From the Stokes’ law we derive v = d g (ρ1 − ρ 2 ) .
18 η
See § 1.1 of Appendix 1 (page 33) for detail of Insert menu.
45
Fig. 27. Solving problems in Maple
Exercises Solve the problems: 1. Poiseill’s principle describes the fluid consumption in a tube of radius r and πr 4 ( P2 − P1 ) , Q being the volume of fluid per unit time, η the viscosity of length l: Q = 8ηl
fluid, P1 and P2 the pressures on the sides of the tube, π=3.1416. Calculate Q for: a) r =0.01, l =0.05, η =0.005, P1 =80 000, P2 =120 000; b) r =0.005, l =0.15, η =0.0055, P1 =90 000, P2 =115 000; c) r =0.007, l =0.10, η =0.008, P1 =95 000, P2 =110 000.
b( P0 − P) , a and b are P+a P constants, P the load and P0 the maximum muscle strength. Since a = 0 , calculate 4
2. Hill function describes the muscle contraction rate V =
46
P+
P0 4 for V=0.005, P=50, P =100; a) the coefficient b = V 0 P0 − P
b) maximum contraction rate (for P = 0) of a muscle for given and found values (see task a); c) V for b = 0.002, P = 60 and P0 = 120; d) the muscle power N for b = 0.0025, P = 40 and P0 = 100 (N = PV).
APPENDIX 3. APPLICATIONS OF SYMBOLIC OPERATIONS WITH EXPRESSIONS § 3.1. Solving Problems by Solving Equations
The solving of some problems consists of two parts: the generations of the equation (often the function is given) and the solving of the equation with respect to the value to be found. Example The dependence of the number of bacteria y on time t after vaccination is
described by the equation y = 1000 +
1000 t . Find time for the bacteria number 1050. t 2 + 100
Solution Since y describes the number of bacteria on time t, the equation for the number of
bacteria 1050 is 1000 +
1000 t = 1050 . Let us solve the equation: t 2 + 100
> solve(1000+1000*t/(t^2+100)=1050,{t});
{ t = 10 }, { t = 10 }
So, the answer is: t = 10. Fig. 28 represents the solving of the problem.
Fig. 28. Solving problems by solving the equations by Maple
47
Note. If the equation has a single solution Maple doubles the result. Evidently, Maple user has to choose the correct variants from the result (adjust in accordance with the properties of the quantity — for instance, to exclude negative values or complex numbers) Exercises 1. Calculate the load to a muscle (see Exercise 2 of § 2.5) for V = 0.002, b = 0.0025, P0 = 120; 2. Absorption of light by solutions is described by the Buger-Lambert-Ber law: I = I0 ⋅ e-χCx, I0 being the initial intensity of light, I the intensity of light traveled through the solution, χ molar absorption index, C molar solution concentration, x the solution depth (path traveled by light in the solution). a) Express and calculate molar solution concentration for I = 18, I0 = 20, χ = 2, x = 0.01; b) Express and calculate molar absorption index of the solution for C = 0.05, x = 0.08, if 10% of light is absorbed. c) What must be the solution depth in task (b) to absorb half of incident light?
§ 3.2. Solving Systems of Equations
To solve a system of equations for some unknowns the system is specified as a set of equations eqns and a set of unknowns vars. The solutions for vars are returned as a set of equations: > solve(eqns,vars);
or > solve({eqn1,eqn2,eqn3,…,eqnn});
where eqn is an equation, eqns is set of equations or inequalities, vars is a set of unknowns to solve for Example Solve the system of equations: x 2 + xy − y 2 = 11 x − 2 y = 1
> solve({x^2+x*y-y^2=11,x-2*y=1}); { y = -2, x = -3 }, { y = 1, x = 3 }
48
Fig. 28. Solving system of equations
Exercises Solve the systems of equations: x 2 + xy − 3 y = 9 a) 3x + 2 y = −1
x 2 + y 2 + 3 xy = −1 b) x + 2 y = 0
u + 2v = 4
c)
2 u + uv − v = −5
§ 3.3. Solving Problems by Solving Systems of Equations Example A homogeneous cylinder of 23 cm height floats in water, 2/3 of its volume being in the liquid. Find the density of the cylinder if the density of water is 1000 kg⋅m-3. Solution Let the density of water be rho, and the density of the cylinder be Rho; V the volume of cylinder in water, A its sectional area, h the height, m the mass, and g the gravity acceleration. Then m = A*h*Rho (1), V = 2*A*h/3 (2).
Since the cylinder is at rest (it nor sinks, neither lifts), the gravity force (m⋅g) is equal to the buoyant force (rho⋅g⋅V): m*g = rho*g*V (3).
Before solving the system of equations (1), (2), and (3), assign the value of rho (density of water is the given value): > rho:=1000; ρ := 1000
49
Note. “:=” is the operator of assignmenti — assigns to the left-hand side of the assignment (that must evaluate to a name, a function call, or an expression sequence of names or function calls, and is evaluated to a name) the value of the right-hand side that is evaluated as an expression.
Now, it’s possible to solve the system of equations: > solve({m*g=rho*g*V,V=A*h/3,m=Rho*A*h}); { A = A, h = 0., m = 0., V = 0., Ρ = Ρ }, { h = h, m = 0., V = 0., A = 0., Ρ = Ρ }, { A = A, h = h, V = 0.3333333333 A h, m = 333.3333333 A h, Ρ = 333.3333333 }
Fig. 29. Solving the problem
In these four sequences of results the first three are just the mathematical results, and they do not give us real result (really, we are not interested in case of zero height and volume of the cylinder {h=0, V=0}, or in zero gravity acceleration {g=0}, or in zero sectional area {A=0}), and let us consider the fourth result: 1) the expressions “h=h”, “g=g”, and “A=A” mean that the result does not depend on gravity acceleration g, height h and sectional area A of the cylinder; 2) the expression “Ρ =1000/3” gives the task solution; 3) the expressions “V=Ah/3” and “m=1000Ah/3” give the formulae for calculation volume of the cylinder in water and its total mass for given A and h. Exercises Calculate the maximum mass of blood passing laminary through aorta crosssection 2 cm diameter in unit time. The blood viscosity is η = 5 mPa⋅s, density ρ = 1460 kg/m3; the Reynolds’ number is 2300ii. i ii
See § 2.4 of Appendix 2 for more detail of use the operator of assignment. Critical Reynolds’ number R indicates the turbulent motion of fluids. R = ρ v d/η.
50
§ 3.4. Expanding Expressions
The primary application of expand is to distribute products over sums. This is done for all polynomials. For quotients of polynomials, only sums in the numerator are expanded — products and powers are left alone. The expand operator also knows how to expand most of the mathematical functions. Call the sequence to expand any algebraic expression expr > expand(expr);
Examples x2 + 3 x + 2
> expand((x+1)*(x+2)); > expand(sin(x+y));
sin( x ) cos( y ) + cos( x ) sin( y )
> expand(cos(2*x));
2 cos( x )2 − 1
Exercises Expand the following expressions: 1. (a − b) 2 ⋅ (a + 2b) ; ( a + b) 3 ; 2. ab sin( x + y ) 3. ; sin( x) sin( y )
4. cos(2 x) ⋅ (1 + 2 cos 2 ( x)) ; (sin( x) + cos( x)) 2 ; 5. sin(2 x) + 1 (sin( x) + cos( x)) 2 . 6. sin(2 x)
§ 3.5. Simplifying Expressions
The simplify function is used to apply simplification rules to an expression. If the only argument is present, then simplify will search the expression for function calls, square roots, radicals, and powers. Next it will invoke the appropriate simplification procedures, that include: trig (for trig functions), hypergeom (for hypergeometrics), radical (occurrence of fractional powers), and power (occurrence of powers), exp, ln. Example > simplify(cos(x)^5+sin(x)^4+2*cos(x)^2-2*sin(x)^2-cos(2*x)); cos( x )4 ( cos( x ) + 1 )
Note. Maple simplifies and expands assigned functions (see Fig. 30).
51
Fig. 30. Simplifying expressions in Maple
Exercises Simplify the expressions: 1. (sin( x) + cos( x)) 2 ; 2a 2 + 3ab − 2b ; 2. 2 a + ab − 2b 2 3. simplify task 5 of § 3.4;
(a 2 +2ab − 3b 2 )(2a 2 + ab − b 2 ) ; 4. (2a 2 + 5ab − 3b 2 )
sin(2 x) + cos(2 x) + sin 2 ( x) i 5. . sin( x) + cos( x)
APPENDIX 4. APPLICATIONS OF ‘PLOT’ OPERATOR § 4.1. Solving Problems by Plotting Graphs
Maple graphic facilities allow the user to visualize the processes that may be described in mathematical language. Example Plot the graph representing the number of bacteria y against time t after
vaccination if the dependence is described by the equation y = 1000 +
Solution Maple plots graphs of functions of various variables: > plot(1000+1000*t/(100+t^2),t=0..100);
i ii
Combine expand and simplify operators. See example problem of § 3.1.
52
1000 t ii . t 2 + 100
Fig. 31. Solving problem in Maple
Exercises 1. The drug-time dependence after insertion is described by the function m = m0 ⋅ e-kt, m0 being the initial mass of drug, k the constant of absorption, e the base of the natural logarithm, t time. Plot the graphs for m0 = 5 mg, t = 10 hours and for b) k = 0.21 hour-1; c) k = 0.31 hour-1. a) k = 0.11 hour-1;
2. Plot the contraction rate against load and muscle power against load graphs (see Exercise 2 of § 1.6) for b = 0.0025, P0 = 100. Make a conclusion of your own about the maximum power of a muscle.
3. The oscillation is described by the equation x = A sin(ω t + ϕ), where A is the amplitude, ω is the angular acceleration, ϕ the initial phase. Find the resultant amplitude and initial phase in the result of addition of two oscillations of the same direction: x1 = 5 sin(2x), x2 = 3 sin (2x + π/2). The resultant amplitude for the codirectional oscillations of the same frequency 2 2 A = A1 + A2 − 2 A1 A2 cos(ϕ 2 − ϕ 1 ) , the initial phase
A1 sin(ϕ 1 ) + A2 sin(ϕ 2 ) . A1 cos(ϕ 1 ) + A2 cos(ϕ 2 )
ϕ 0 = arctan
Plot the resultant oscillations with the amplitude A, the initial phase ϕ0 (the resultant oscillation will have the same frequency as the initial ones) together with the initial oscillations. 53
§ 4.2. Parametric Plots
A parametric property cannot be expressed as a single name. This corresponds to cases where it’s necessary to define classes of properties, and the arguments to the parametric property are the values that identify the particular property within the class. An example of parametric property is the link of x and y, both depending on time. A parametric plot is specified by a list of three items; the first two are real functions of a parameter, the third is the range for the parameter: >plot([x(t),y(t),t=range of t],h,v);
where h is horizontal range, and v is vertical range. If there is no input of h and v default is used (see the Example). Example > plot([sin(t), cos(t), t=-Pi..Pi]);
Fig. 32. Parametric plot in Maple
54
Exercises Make the following parametric plots for ϕ0 = 0, π/4, π/2 (that are also known as Lissajous’ figures): 1. x = sin( 2t ), y = sin( 2t + ϕ 0 ) ; 3. x = sin(3t + ϕ 0 ), y = sin(t ) ; 2. x = sin( 4t + ϕ 0 ), y = sin( 2t ) ; 4. x = sin(2t ), y = sin(3t + ϕ 0 ) . § 4.3. Three-Dimensional Plots
To make a three-dimensional plot it’s necessary to make the following calling sequence: >plot3d(expr, x=a..b, y=c..d);
In the call, the expression expr must be a Maple expression in the names x and y. The range a..b must evaluate to real constants. The range c..d must either evaluate to real constants or be expressions in x. They specify the range over which expr is plotted. The call sequence describes surface plots in Cartesian coordinates. The ranges must be given simply in the form a..b, rather than as an equation. The second range c..d can have arguments evaluating to real constants or procedures of one variable (see the example in Fig. 33).
Fig. 33. Three-dimensional graph in Maple
55
The right-click context menu allows the user to change the projection, colour and style, and to display the normal, framed, and boxed axes. Fig. 33 represents the plot with no axes; Fig. 34 represents the same plot with boxed axes.
Fig. 34. Three-dimensional graph with boxed axes
Exercises Plot three-dimensional graphs the following functions:
1. xy −
1 ; x = (−1,1), y = (−1,1) ; xy
4. x 3 y − xy 3 ; x = (−1,1), y = (−1,1) ;
2 xy ; x = (−1,1), y = (−1,1) ; x− y x+ y ; x = (−1,1), y = (−1,1) ; 3. x− y
5. sin( xy ); x = (− π, π), y = (− π, π) .
2.
56
APPENDIX 5. APPLICATIONS OF DIFFERENTIAL CALCULUS § 5.1. Plotting Tangent Lines
To plot the tangent line to a given function f(x) at a given point a it’s necessary to obtain the equation of the tangent line. The equation of a line depends on two coefficients k and b: y = k*x + b. So, to plot a tangent line to a given function at the definite point it’s necessary to know k and b. It’s necessary to make three steps to plot a tangent line to a given function at the definite point. The first coefficient (k) is equal to the value of the derivative of the function at a given point. Now, step 1, the derivative of the function at the given point gives the coefficient k: > limit(diff(f(x),x),x=a); k
Since the values of the function f(x) and the expression of the tangent line (kx+b) are equal to each other at the point of ploting the line, the second coefficient (b) may be found by making equal the values of the function and the function of the line at the point. Last, solve the found equation with respect to b. Now, step 2, the solution of the equation gives the coefficient b: > solve(f(a)=k*a+b,b); b
f(a) being the value of the function for x=a.
The last, step 3, plot the graphs of the function and the tangent line to the function at the given point: > plot([f(x),k*x+b],x=c..d);
c and d being the points surrounding the given a. Note. To plot two or more graphs together their functions must be written in braces separated by coma (see the last command prompt). Example Plot a tangent line to the function y = x2 at the point x = 1. 1) Step 1, find the value of the derivative of the function at the given point: > limit(diff(x^2,x),x=1); 2
So, k = 2.
57
2) Now, step 2, equate yx=1 to the expression (k*x+b, k=2, x=1) of the line and solve the found equation with respect to b (second coefficient): > solve(1^2=2*1+b,b); -1
3) Since the second coefficient is already known (b= –1), then the equation of the tangent line is: y = 2*x - 1, and now (step 3) it’s possible to plot the graph (see Fig. 35).
Fig. 35. Plotting tangent line to a graph in Maple
Exercises 1. Plot the tangent line to the graph of the function y=x3 at the point x=2. 2. Plot the tangent line to the graph of the function y=ex at the point x=0. 3. Plot the tangent line to the graph of the function y=ln x at the point x=1. 4. Plot the tangent line to the graph of the function y=1/x at the points x=1, x=2. 58
§ 5.2. Solving Problems by Using ‘diff’ Operator
By setting derivative of the function to zero it’s possible to find the argument for the maximum (and/or minimum) value of the function. It is widely used for solving various problems. Example The dependence of the number of bacteria y on time t after vaccination is
described by the equation y = 1000 +
1000 t . Find the maximum number of bacteria t 2 + 100
and time for maximum number of bacteria. i
Solution To find time for maximum number of bacteria it’s necessary to set the derivative of y to zero and solve the equation with respect to time: > solve((diff(1000+1000*t/(t^2+100),t)=0),{t}); { t = -10 }, { t = 10 }
Since we are not interested in the negative value of time, time of maximum bacteria number is t = 10. Now let us find the maximum number of bacteria: > limit(1000+1000*t/(t^2+100),t=10); 1050
The graph of the function is the visualization the solution (see Fig. 31). Exercises Solve the problems:
1. A single muscle shortening is described by Rayleigh equation y = bte , where t is time; b and k are constants. Find the shortening rate of a muscle. 2. The electrical impedance of biological substance may be described by the equation Z = R 2 + (ω L − 1 / ω C ) 2 , R being the resistance, L the inductivity, C the capacity, ω the angular frequency. Find the value of the angular frequency for the highest impedance; R, L and C being constant. Characterize the frequency found. 3. Calculate the load to a muscle for the maximum muscle power (see Exercise 2 of § 2.5) for P0 = 100. Compare the result with the graph (Exercise 2 of § 4.1) and put down the result in percentagewise form with respect to P0. 4. Calculate the oxygen percentage y in gas mixture for the maximum oxidation −
rate of nitrogen, if equations for the process are y = k ( x − x ) and x + k being constant, x being the nitric oxide percentage concentration (range 0..1). 2
i
See example problems of § 3.1 and of § 4.1, Fig. 31.
59
3
kt 2 2
y = 1,
5. Patient reaction to medicine is described by the function f ( x) = x 2 (a − x) , a being positive constant, x being the amount of medicine. Find the value of the amount of medicine for the maximum reaction.
APPENDIX 6. APPLICATIONS OF INTEGRAL CALCULUS § 6.1. Calculating an Area of a Plane Figure Bounded by Lines
The way described below is useful when the sides of a figure are not straight lines and the area of a figure may not be found as the product. Such area may represent the distance traveled by an object (the coordinates are velocity and time), work done by a system (the coordinates are force and distance, pressure and volume, or power and time), etc. Suppose, the lines are described by functions f1(x) and f2(x). To calculate the area bounded by the lines it’s necessary to make the two steps described below. Step 1 is finding the points of the functions’ intersections (x1, x2) — solving an equation that is produced by equating the functions. Then, step 2, the definite integral of a difference of the functions at the given interval [x1, x2] must be taken, and the found value is the area of the figure. Note. The points of the functions’ intersections that are found in step 1 are the endpoints of the definite integral in step 2. In case of a single point of intersection of the functions the second endpoint of integration is usually given. Example Calculate the area of a figure bounded by curves y = 4 — x2 and y = x2 — 4.
Step 1, find the points of intersection of the functions by equalizing the functions and solving the resultant equation: > solve(4-x^2=x^2-4,x); -2, 2
Then, step 2, calculate the definite integral of the difference of the functions (the points of intersection of the functions are the endpoints of the interval of integration — see Note): > int((4-x^2)-(x^2-4),x=-2..2); 64 3
Last, the graph of the resultant figure may be plotted (see Fig. 36):
60
Fig. 36. The graph of the figure bounded by lines
Exercises Calculate the area of a figure bounded by the lines: 1. y = x 2 + 2 , y = x + 4 ; 2. y = x 2 − 2 x − 3 , y = − x 2 − 6 x − 3 ; 2 3. y = x , y = 2 − x ; 4. y = x 2 + 3 , y = 19 ; 5. y = − x 2 + 4 x − 3 , y = 6 − 2 x , x = 0 ; i 6. y = x 2 − 2 x + 2 , y = 4 x − 7 , x = 0 ;
i
Since the functions have a single point of intersection, the second endpoint of integration is given.
61
§ 6.2. Double Integrals
Double integrals may be found by doubling int operator: >int(int(y(x),x),y); >int(int(y(x),x=a..b),y=c..d);
The first example represents the indefinite double integral the second is the definite one, a and b being the endpoints of integration of variable x, c and d are the endpoints of integration of variable y. Note that the separation of variables is obligatory: one (x) must be defined in the internal integral; another (y) must be in the outer one. Example > int(int(x*y,x),y); x2 y2 4
> int(int(x*y,x=0..1),y=0..1); 1 4
Since Int is the inert for of int operator, for displaying the unevaluated form of double integral it’s necessary to use both inert operators (see Fig. 37), else the partial evaluation is done.
Fig. 37. Double integrals in Maple
62
Exercises Calculate the rectangular range integrals:
1.
y ∫∫ x dxdy; 1 ≤ x ≤ e, 4 ≤ y ≤ 6 ;
3y 2 dxdy; 0 ≤ x ≤ 1, 0 ≤ y ≤ 1 ; 2. ∫∫ 1+ x2
3. 4.
5.
∫∫ (3 yx
∫∫ xe
xy
2
− 2 x 3 )dxdy; 0 ≤ x ≤ 1, 1 ≤ y ≤ 2 ;
dxdy; 0 ≤ x ≤ 1, − 1 ≤ y ≤ 0 ;
dxdy ∫∫ ( x − y) 2 ; 1 ≤ x ≤ 2, 3 ≤ y ≤ 4 .
§ 6.3. Solving problems by using ‘int’ operator
There are many problems that may be solved by applying integral calculus. In the problems, the result is the product of two values, one being the independent variable of given range (for instance, time), another the function of the variable (velocity, force, pressure, current, potential difference, etc.). The Example below describes the solving of such problems. Example Calculate the distance travelled by the object during the first 4 seconds. The velocity of the object is described by the equation v = 0.8x – 2x+4. Solution Since the unit distance travelled by an object is defined as dS = vdt, the total
distance is found by using the definite integral S = ∫ vdt , a and b being the endpoints of b
a
integration — the initial (0 seconds) and the final (4 seconds) moments of time: > int(0.8*x^2-2*x+4,x=0..4); 17.06666667
So, the distance travelled by the object during the first four seconds is 17.06666667. The graph below displays dependence of the velocity on time, the area below the curve is numerically equal to the distance travelled by the object.
63
Fig. 38. Solving problems by using 'int' operator
Exercises Solve the problems: 1. Calculate work W i done by the force F = 10 − 2 x at distance 2 m.
2. Calculate charge Q passed through the conductor during the first 5 seconds. The currentii flowing through the conductor is described by the equation I = 10 ⋅ e-0.2t. 3. Calculate work done Wiii by the ideal gas. The initial volume is 0.2 m3; the
final volume is 0.7 m3. The pressure p is described by the equation p =
6000 , V being V
the ideal gas volume.
i ii
Work done by force F at the displacement dx is defined as dW=F⋅dx. Electric current is defined as I = dQ , Q being charge passed through the conductor during time t. Work of an ideal gas is defined as dW = p⋅dV. dt
iii
64
APPENDIX 7. APPLICATIONS OF SOLVING DIFFERENTIAL EQUATIONS § 7.1. Differential Equations with Initial Conditions
The basic task being performed by dsolve when solving an "Initial Conditions" (ICs) ODE problem is to find appropriate values for the set of integration constants _Cn appearing in the symbolic solution of the problem, such that the solution will match the given ICs. As general rules for IC problems, the first argument must be a set containing an ODE together with the ICs, the second argument must be a set containing the indeterminate functions of the problem: i >dsolve({ODE, ICs}, y(x));
For symbolic problems (that is, when neither series nor numeric solutions were requested) a typical IC can be any equation relating algebraic expressions, or just the algebraic expressions themselves, then assumed to be = 0. The derivatives entering the ICs can always be expressed using the D syntax (for example D(y)(0)=1, D(y)(A+B)=C). If the evaluation points are of type symbol, diff will also work (for example, diff(y(a),a)=1 means that the derivative of y at a must be 1). Example Solve differential equation y ′ = −ky , if y (0) = 10 . > dsolve({diff(y(x),x)=-k*y(x),y(0)=10},y(x)); y( x ) = 10 e
( −k x )
Exercises 1. y ′ = x + 1, y ( 2) = 0 ;
1 e3 2 2. y ′ = + x , y (e) = 1 + ; 3 x 3. y ′ = e x + 2e − x , y (0) = 3 ; π 3
4. y ′ = − sin( x), y = 1 ; 5. (1 + x ) y ′ = 1, y (1) = 5 .
i
The number of initial conditions should not be greater than the order of given differential equations.
65
§ 7.2. Solving Problems by Differential Equations
The solving of problems by differential equations consists of two parts — the generation of differential equation and solving the generated equation. Example The dissolution rate of drug is proportional to its amount. Determine the initial amount of the drug if in an hour its amount was 31.4 g and in three hours it was 9.7 g. Solution 1. (Generation of differential equation) Let y(x) be the amount-time dependence of drug, x being time (independent variable). Then, the proportionality of the drug dissolution rate to its amount may be mathematically expressed as y′(x)= –a*y(x),
a being a constant. Since the increase of dissolution rate makes the amount of drug decrease faster, then the negative sign is placed in the right part of the differential equation.
2. (Solving the equation) There are two initial conditions in the problem: y(1) = 31.4 and y(3) = 9.7. When solving the differential equation first use one of the conditions: > dsolve({diff(y(x),x)=-a*y(x),y(1)=31.4},y(x)); ( −a x )
157 e y( x ) = 5 e ( −a )
Then use another given condition: since y(3)= 9.7, it follows 9.7=31.4*e(-a* 3)/e(-1* a). Now solve the last equation with respect to a: > solve(9.7=31.4*exp(-a*3)/exp(-1*a),a); 0.5873410037
So, a = 0.5873410037 or a ≈ 0.59. Substitute the value of a to the equation: > (31.40000000*exp(-.5873410037*x)/exp(-1.*.5873410037)); 56.49481685 e
( −0.5873410037x )
or, being approximated, 56.5 e
( −0.59 x )
At last, the approximate form of the function is y ( x ) = 56.5 e −0.59 x . 66
By calculating the limit of this function for x=0, find the answer of the problem: > limit(56.5*exp(-0.59*x),x=0); 56.50000000
The answer is 56.5 g. Plot the graph of the function: > plot(56.5*exp(-0.59*x),x=0..4);
Fig. 39. The graph of a function
67
Exercises Solve the problems: 1. Enzymatic reaction is proportional to the amount of enzyme. The initial enzyme amount is 1 g, the enzyme amount in an hour is 1,2 g. Calculate the enzyme amount in 5 hours.
2. The cooling rate of an object in proportional to temperature difference of the object and its environment. The initial temperature of the object is 30 degrees, in 30 minutes it becomes 22.5 degrees. What is the temperature in 3 hours if the temperature of the environment is 0 degrees. 3. The salt dissolution rate is proportional to the concentration difference of saturated and current solutions. Determine the concentration-time dependence, if the initial concentration is a, and the saturated solution concentration is b.
APPENDIX 8. HOW TO USE MAPLE HELP § 8.1. Introduction and New User’s Tour
Maple provides a complete online help system including Introduction, Help on Maple, New User’s Tour, News of the Last Version (What’s New), Using Help, Glossary, Topic Search, Full Text Search, Help History, Maple on Web, About Maple, etc. (see Fig. 40), so everyone can use to find information about a specific topic or command easily. Choose Help menu to observe the options.
Fig. 40. Maple Help menu
68
Choose Introduction option of Help menu and get the following list of topics to explore: •
•
•
New User's Tour What's New
•
Overview of Basic Features
•
Worksheet Interface
•
Worksheet Toolbar
• • •
Using Help Overview of Menu Bar Help Style Guide Exit Maple
New User's Tour provides a quick tour of the features of Maple, What's New provides an overview of the features that are new in the version installed, Overview of Basic Features describes the main features of Maple that the user requires to know to get started using Maple, Using Help describes the various ways to use the Maple Help, Worksheet Interface describes a Maple worksheet, Overview of Menu Bar describes the menu bar and the various sets of menus available, Worksheet Toolbar describes the buttons on the various toolbars, Help Style Guide describes the various character styles used on the help pages, Exit Maple describes how to leave Maple. Choose the New User’s Tour and get the starting worksheet of the Tour. Click the last line to begin the Tour, and get the Topic List of the New User’s Tour: (1) Working Through the New User's Tour (2) The Worksheet Environment (3) Numerical Calculations (4) Algebraic Computations (5) Graphics (6) Calculus (7) Differential Equations (8) Linear Algebra (9) Finance and Statistics (10) Programming (11) Online Help (12) Summary
The Topics give the information the new Maple user has to know to get started using Maple. Explore the Topics and use Click here to go to the next topic and Click here to return to the Main Menu hyperlinks at the end of the worksheet to go to the desired point of the New User’s Tour.
69
§ 8.2. Using Help Using Help is the fifth option of Maple Help menu (see Fig. 41).
Fig. 41. Using Help option of Maple Help menu
The starting ‘using help’ worksheet has two general sections — Finding Information and Help Menus and Toolbars, every containing topic lists (see below). Finding Information •
•
Perform a Topic Search
•
Use the Help Browser
•
Perform a Full Text Search
•
Display a Known Help Topic
•
Display Balloon Help
•
Context-Sensitive Help Review Help History
The list Finding Information represents different ways to find the help topics. Help Menus and Toolbars • •
Overview of Help Menu
•
Help Toolbar
•
Overview of Help Page Menu Bar Status Bar
70
The list Help Menus and Toolbars contains the descriptions of the menus, menu items, and toolbar buttons displayed when viewing Maple help pages. You can also explore Glossary from the starting ‘using help’ worksheet or by choosing the corresponding option of Maple Help menu (see Fig.40). § 8.3. Topic Search and Full Text Search Topic searches in the Maple help system are based on a specified keyword.
Choose Topic Search from the Help menu. Select the Autosearch check box, and you will see the list of Matching Topics as you type in the letters of the topic search word. Enter the name of the topic you are looking for in the Topic text box.i Click on a topic from the list of Matching Topics to select its help page for display.
Fig. 42. Topic Search window
Full text searches in the Maple help system find Help Topics containing given words. Choose Full Text Search from the Help menu. Enter the word(s) you want to find in the Word(s) text box. Click Search to obtain a list of topics that contain the word(s) you entered. If you enter more than one word, the list includes topics that contain one or more of the words entered. Click on a topic from the list of Matching Topics to select its help page for display.
Fig. 43. Full Text Search window
i
If Auto-search is not selected, click Search to display the list of Matching Topics.
71
KEY TO THE EXERCISES Lesson 2. 1. 32; 2. 3375; 3. 3506.955753; 4. 2.236067978; 5. 1; 6. 9.
1 ; 10. 30.5; 11. 4; 12. 110592; 13. –6, 4, 3; 14. –6, 33, 0, 2
2 sin( 2) + cos(1) , 2 sin( 4) + cos( 2) ; 16. π, Lesson 3. 1. 1, 8.
1 π , 1.316957897*I. 2
1 ; 7. − 3 ; 8. − 1 ; 2
2 −1 1 2, ; 15. 1, 2 + 2 2
4 ; 2. − 2 − 17 , − 2 + 17 ; 3. 8; 4. 4; 5. 7; 6. 2, 4; 7. -1.057735498; 3
1 π , − 3 π ; 9. 1 1 + 41 , − 1 1 + 41 , 1 1 − 41 , − 1 1 − 41 ; 10. 0, 4 4 2 2 2 2
Lesson 5. 1. −
1 1 − ln( x) − ; 2. sin(ln(x)) + cos(ln(x)) ; x(1 + ln( x)) (1 + ln( x)) 2 x
− 5,
2 . 3
20 1 4 9 4x5 + 2 − ; 3. 2sin(x) sin(x ) cos(x) + 2sin (x) cos(x ) ; 4. 27 9 (4 x 5 + 2) 8 3 x5 2
2
2
2 1 7 2 tan(5 x) (2 + 2 tan (5 x)) e−x − x2 5. ; ; 6. − 2 x e ln( x) + 7 tan(5 x) x 2
3e 2e sin( 2 x) 3x 2 3 (1 + x 3 ) x 2 1 − x 3 1 + ⋅ 6 cos π + 3 x ; 9. + 7. ; 3 3 2 3 ; 8. cos(2 x) cos 2 (2 x) (1 − x ) 1 + x 3 1− x 1 1+ 2 x10 x 2 x 43 6 2 x 10. − ; ; 11. 5 sin cos ; 12. 5 x x − 8 + 6 2 4 3 3 3 3 ( 8 ) x − (x + x ) 3x
3x
2 5 20 x ln 3 ( x + 3) . 13. 3 x2 + 3 1 2 cos( x ) 5 5 3 2 ( x + 1) 4 ; 4. ( 2 + x ) 5 ; 2. − e x 2 − 10 x ; Lesson 6. 1. ; 3. 2 12 5 1 2 20 271 2 3 2 2 2 ; 8. x −4 x − ( x 2 + 1) 3 ; 7. − + ; 6. 5. ; 9. ; 10. 2; 3 3 3 3 6 3 x 1 1 1 1 11. ln(3) − ln(5) ; 12. ln(29) − ln(5) . 2 4 2 2
arctan( x ) Lesson 7. 1. C1e ; 2.
5.
3
3 ln(1 + e x ) + C1 ;
C1 tan( x)
1 + tan ( x) 2
; 3.
3
13 12 x 2 + 8C1 . 2
72
3 x − 3 x 2 + C1 ; 4.
2 − cos( x) + C1 sin( x) ; 3 sin( x) 3
Lesson 8. 1. mean =
4549 305 185489 , median = , var iance = , 30 2 900 2027 1 , 185489 ; 2. mean = 93.1 , median = 93 , var iance = s tan dard deviation = 300 30 1 6081 . s tan dard deviation = 30
Appendix 2. §2.1. 1. 1.0986; 2. 0.35355; 3. 0.75983; 4. 0.5040; 5. 7.389056099; 6. 5.294490050; 7. 2.809925894; 8. 4.442882938; 9. 1.5849; §2.2. I. 1. 1.5498; 2. 288; 3. 47.02; 4. 280.34; 5. e; 6. 4.
π2 6
; 7. –0.5; II. 1. 14400; 2. 21600000; 3. 20;
1105 1 91 1 2 ; 5. ; 6. 96; 7. ; §2.3. 1. 1; 2. 0.5; 3. ; 4. ; 5. ∞; §2.5. 1. a) 0.628; 18 72 8 4 2
b) 0.315; c) 1.18; 2. a) 0.0025; b) 0.10; c) 0.00133; d) 0.0000115. Appendix 3. §3.1. 1. 53.3; 2. a) 5.268; b) 26.34; c) 0.5263; §3.2. a) {x = 3, y = –5},
{x = 5, y = –8}; b) {y = 1, x = –2}, {x = 2, y = 1}; c) {u = –2, v = 3}, {u = -3, v = 3. 0.723.
Appendix 6. §6.1. 1.
π 9 8 9 256 1 ; 2. ; 3. ; 4. ; 5. 9; 6. 9. §6.2. 1. 10; 2. ; 3. 1; 4. ; 2 3 2 3 4 e
4 5. ln ; §6.3. 1. 16; 2. 31.6; 3. 7516.6. 3
1 1 1 2 x + x − 4 ; 2. x 3 + ln( x ) ; 3. e x − 2e − x + 4 ; 4. cos( x ) + ; 3 2 2 5. ln( x + 1) − ln( 2) + 5 ; §7.2. 1. 2.46; 2. 5.43.
Appendix 7. §7.1. 1.
73
7 }; 2
INDEX antiderivative, 18 area of a plane figure, 60 arithmetic operators, 10 assignment operator, 44 back menu, 32 bidirectional limit, 42 close menu, 26 color parameter, 24 command prompt, 7 constant of integration, 18 context bar for 2-D plots, 34 context bar for 3-D plots, 35 context bar for animations, 35 context bar for Maple input, 36 context bar for Maple output, 36 context bar for spreadsheets, 37 context bar for text regions, 37 context bar menu, 30 copy as Maple text menu, 27 cut menu, 27 definite integration, 18 delete paragraph menu, 27 derivative of a function, 16, 20 describe subpackage, 22 diff operator, 16, 20 differential equation, 20 differential equations with IC, 65 directional limit, 42 double integral, 62 dsolve operator, 20 edit menu, 27 endpoints of integration, 18 entry mode menu, 29 evalf function, 39 execution group, 7 exit menu, 26 expand operator, 51 export as menu, 26 file menu, 26 find menu, 27 finite sums, 40 forward menu, 32 group range, 7 histogram operator, 24 horizontal range of plot, 14 hyperlinks menu, 28 indefinite integral, 18 infinite sums, 40 insert menu, 33 int operator, 18 limit function, 42 Maple input, 7, 33 Maple online Help system, 68 Maple operators, 10 Maple output, 7
mean operator, 22 median operator, 22 new menu, 26 numbars parameter, 24 open menu, 26 open URL menu, 26 operator of approximation, 39 operator of assignment, 50 operator of exponential function, 10 operator of logarithm, 10 operator of solving differential equations, 20 operators of inverse trigonometric functions, 10 operators of trigonometric functions, 10 palette, 30 parametric plot, 54 paste Maple text menu, 27 paste menu, 27 plot of multiple functions, 14 preferences menu, 26 print menu, 26 print preview menu, 26 product command, 40 redo menu, 27 remove output menu, 29 right-click context menu, 37 save as menu, 26 save menu, 26 select all menu, 27 send menu, 26 simplify function, 51 solve operator, 13 solving of problems by differential equations, 66 solving system of equations, 48 spellcheck utility, 28 standard math notation, 33 standarddeviation operator, 23 statplots subpackage, 23 stats package, 22 status bar, 30 sum command, 40 tangent line to a function, 57 text menu, 33 three-dimensional plot, 55 toolbar, 30 two-dimensional graph, 14 undo menu, 27 unit converter menu, 28 variance operator, 23 vertical range of plot, 14 view menu, 30 with command, 22 worksheet, 7 worksheet files, 7 zoom factor, 32
74
REFERENCES 1. / «
2. . 3. -
.
.—
.:
. . », 2002. —432 . . . « », ., 1978.
.
: . ., 1997. — 190 . .—
:
/
.
.
: .-
.
4. : . . 2 . — 5., . — .: . ., 1999. — 416 .: . 5. . . . : . . . .. . ( . № 2104 2105). 4., . — .: , 1973. 6. . Maple 7: .— .: , 2002. — 672 .: . 7. : . / . . Щ . — 3., . — .: . ., 2002. — 304 .: . 8. . . : .— .: , 1998. — 232 .: . 9. Mathcad: .. / . .– : , 2003. — 40 . 10. : . . . . . — .: , 2001. — 352 . 11. . . . : . . — 2., . . – .: , 2001. 192 .: . 12. . ., . . Maple: . – : , 2001. – 116 . 13. . . : . . « ». – : , 2003. – 84 . 14. . ., . . .— : . — 2001, 66 . 15. New Understanding PHYSICS For Advanced Level / Jim Breithaupt. — Fourth Edition. — Nelson Thornes Ltd, 2000. 16. PHYSICS: principles with applications / Douglas C. Giancoli. — Fifth Edition. — PRENTICE HALL, 1998. 17. The New Penguin Compact English Dictionary. Consultant editor: Robert Allen. Merriam-Webster Inc. and Longman Group Ltd, Penguin Books Ltd. London. 2001. 18. The Penguin Dictionary of Physics. Editor: Valerie H. Pitt. LAURENCE URGANG ASSOSIATED LTD. New York. 1977. 19. The Wordworth Dictionary of Science and Technology. This edition published 1995 by Wordworth edition Ltd, Cumperland House, Crib Street, Ware, Hertfordshire SG 12 9ET. Copyright © W&R Chamber Ltd and Cambridge University Press 1988. 75
76