scientific workplace demonstration document

Upload: geeorgi23

Post on 03-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    1/31

    Scientic WorkPlace Demonstration Document

    Roger Hunter and Fred Richman and John Thomas and Elbert Walker

    Contents

    1 Introduction 3

    2 Getting Started 32.1 Where to Place the Insertion Point . . . . . 32.2 How Scientic WorkPlace Selects an Ex-

    pression . . . . . . . . . . . . . . . . . . . . 32.3 Selecting Expressions for Operations . . . . 42.4 A Keyboard Shortcut for Evaluate . . . . . 42.5 Stopping a Computation . . . . . . . . . . . 42.6 The Settings Menu . . . . . . . . . . . . . . 4

    3 Working with Expressions and Functions 53.1 The Slash Operator (/) . . . . . . . . . . . 5

    3.2 Standard Mathematical Functions . . . . . 63.3 More Operations . . . . . . . . . . . . . . . 73.4 Some Special Operations and Commands . 73.5 Constants . . . . . . . . . . . . . . . . . . . 83.6 Polynomials . . . . . . . . . . . . . . . . . . 83.7 Limits . . . . . . . . . . . . . . . . . . . . . 93.8 Dierentiation . . . . . . . . . . . . . . . . 93.9 Indenite Integration . . . . . . . . . . . . . 93.10 Sequences of Operations . . . . . . . . . . . 103.11 Denite Integrals . . . . . . . . . . . . . . . 103.12 Numerical Integration . . . . . . . . . . . . 113.13 Innite Series . . . . . . . . . . . . . . . . . 113.14 Substituting a Value into an Expression . . 11

    4 Matrices 114.1 Standard Operations . . . . . . . . . . . . . 114.2 The Matrices Submenu . . . . . . . . . . . . 12

    5 Solving Systems of Equations 135.1 Solve Exact . . . . . . . . . . . . . . . . . . 135.2 Solve Numeric . . . . . . . . . . . . . . . . . 145.3 Solve Integer . . . . . . . . . . . . . . . . . 145.4 Solve Recursion . . . . . . . . . . . . . . . . 14

    6 Modular Arithmetic 146.1 The Integers modulo m . . . . . . . . . . . 14

    6.2 Matrices Modulo m . . . . . . . . . . . . . . 156.3 Polynomials Modulo m . . . . . . . . . . . . 156.4 Polynomials Modulo Polynomials . . . . . 15

    7 Denitions 157.1 New Denition, Undene, Show Deni-

    tions, and Clear Denitions . . . . . . . . . 157.2 Denitions with Deferred Evaluation . . . . 187.3 Remembering Solutions . . . . . . . . . . . 187.4 Save Denitions & Restore Denitions . . . 18

    7.5 Functions of Several Variables . . . . . . . . 187.6 Row and Column Arguments . . . . . . . . 187.7 Matrix Valued Functions . . . . . . . . . . . 197.8 Piecewise-Dened Functions . . . . . . . . . 197.9 Access to Other Maple Functions . . . . . . 197.10 User Dened Maple Functions . . . . . . . . 19

    8 2D Plots 208.1 Frame Properties Dialog Box . . . . . . . . . 208.2 Plotting More than one Function at a Time . 208.3 Plot Components Page . . . . . . . . . . . . 218.4 Axes & View Page . . . . . . . . . . . . . . . 218.5 Plotting Points . . . . . . . . . . . . . . . . . 218.6 Conformal Plots . . . . . . . . . . . . . . . . 21

    8.7 Plots of Vector and Gradient Fields . . . . . . 218.8 Parametric Equations . . . . . . . . . . . . . 228.9 Implicit Equations . . . . . . . . . . . . . . . 228.10 Polar Coordinates . . . . . . . . . . . . . . . 228.11 Parametric Polar Plots . . . . . . . . . . . . 22

    9 3D Plots 229.1 Plotting Tools for 3D Plots . . . . . . . . . . 229.2 Implicit Functions . . . . . . . . . . . . . . . 239.3 Parameterized Surfaces . . . . . . . . . . . . 239.4 Curves in Space . . . . . . . . . . . . . . . . 239.5 Cylindrical Coordinates . . . . . . . . . . . . 239.6 Parameterized Surfaces in Cylindrical Coordi-

    nates . . . . . . . . . . . . . . . . . . . . . . 249.7 Spherical Coordinates . . . . . . . . . . . . . 249.8 Parameterized Surfaces in Spherical Coordinates 249.9 Exercises . . . . . . . . . . . . . . . . . . . . 249.10 Solutions to Exercises . . . . . . . . . . . . . 24

    10 Calculus 2510.1 Implicit Dierentiation . . . . . . . . . . . . 2510.2 Iterate . . . . . . . . . . . . . . . . . . . . . 2510.3 Find Extrema . . . . . . . . . . . . . . . . . 2510.4 Methods of Integration . . . . . . . . . . . . 2610.5 Pictures of Riemann Sums . . . . . . . . . . 2610.6 Approximation Methods . . . . . . . . . . . . 26

    11 Dierential Equations 2711.1 Exact Methods . . . . . . . . . . . . . . . . . 2711.2 Initial Value Problems . . . . . . . . . . . . . 27

    12 Vector Calculus 2812.1 Dot and Cross Products . . . . . . . . . . . . 2812.2 Vector Norms . . . . . . . . . . . . . . . . . 2912.3 Gradient, Divergence and Curl . . . . . . . . 2912.4 Hessian . . . . . . . . . . . . . . . . . . . . . 2912.5 Jacobian . . . . . . . . . . . . . . . . . . . . 29

    2

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    2/31

    12.6 Curl and Vector Potential . . . . . . . . . . . 3012.7 D ivergence . . . . . . . . . . . . . . . . . . 30

    13 Statistics 3013.1 Lists and Matrices . . . . . . . . . . . . . . 3013.2 Mean, Median, Mode, Moment, Quantile,

    Mean Deviation, Standard Deviation, andVariance . . . . . . . . . . . . . . . . . . . . 30

    13.3 Correlation and Covariance . . . . . . . . . . 31

    13.4 Random Numbers . . . . . . . . . . . . . . . 3113.5 Distributions and Densities . . . . . . . . . . 31

    Introduction

    The work on this interface between Scientic Word andMaple was supported by a National Science FoundationSBIR (Small Business Innovation Research) grant. Thegoal is to provide an interface which:

    1. Uses natural mathematical notation only, and

    2. Uses free-form editing.

    Scientic Word's interface satises both criteria. Allof the signicant problems arise from the free-form require-ment. Maple and Mathematica both have notebook sys-tems which use the natural form for output, but whichinsist upon complete, syntactically correct, mathematicalexpressions, allowing the user only minimal variation inways to enter a given expression. We want to make senseout of as many dierent forms as possible, not requiringthe user to adhere to a rigid syntax or just one way of writ-ing an expression. For example, it is essential that bothRdxx

    andR

    1x

    dx be acceptable. The ease of use is furtherenhanced by the acceptance of incomplete forms which areoften seen in the literature, such as Rx2 for Rx2dx.

    This implementation covers much of high school andundergraduate level mathematics, and is a useful mathe-matical tool. Also, it has great potential as a classroomdevice and is being tested in this regard. The combina-tion of a free form scientic word processor and compu-tational package makes it a possible replacement for theblackboard.

    The system consisting of Scientic Word and its in-terface to Maple is called Scientic WorkPlace. It is newand dierent and we are very interested in receiving feed-back from our users. Any suggestions or reactions wouldbe appreciated. Our address is

    TCI Software Research1190 Foster RoadLas Cruces, NM 88001tel 505-522-4600fax 505-522-0116email [email protected]

    Getting Started

    The current system is described using a series of examplesthat you can try. These examples range from trivial arith-

    metic to advanced linear algebra. They include completecomputations and various pathologies and oddities. Thisle is write protected so that computing in it won't messit up. And you can save it under some other name anduse the new le to play with. In any case, we suggest thatyou print out a copy. Then you can nd quickly examplesand explanations of computations of various kinds, usingthe table of contents. The document is loosely structuredaround the Maple menu.

    Before you start, check that the word Maple appearson the menu at the top of the Scientic WorkPlace windowto the right of Tools. If not, your installation is incomplete.

    We'll start with two examples of factoring.

    Factoring a Number Place the insertion point withinthe number 234567890 and from the Maple menuchoose Factor. Note that the answer is placed imme-diately to the right, following an = sign. The result,; 2 325 3803 3607, contains only where nec-essary. The presence of the superscript following the3 means that is not necessary before the following5. Scientic WorkPlace automatically chooses integer

    factorization.Factoring a Polynomial Place the insertion point

    within x5 + 7x3 41x4y 41x2y + 80x3y2 + 80xy2 52y3x2 52y3; = x2 + 1 (7x 13y) (2y + x)2 andchoose Factor from the Maple menu. Scientic Work-Place automatically chooses polynomial factorization.

    Where to Place the Insertion Point

    Scientic WorkPlace shows mathematics in red. Whenthe insertion point is within mathematics, the Math/Texticon at the top of the screen displays a red M. When wesay \place the insertion point in the following expression",

    anywhere that shows the red M is sucient. Valid posi-tions are anywhere within, or immediately to the right of,the expression. The position immediately to the left of theexpression is not valid.

    Expand Place the insertion point in the expression x 2y)2(7x 13y)(x2 + 1) and from the Maple menuchoose xpand. You should get the polynomial in theprevious example x 2y)2(7x 13y)(x2 +1) = 7x5 +7x341x4y41x2y +80x3y2+80xy252y3x252y3,of course.

    How Scientic WorkPlace Selects an Expression

    When you place the insertion point in a mathematical ex-pression and choose an operation from the Maple menu,Scientic WorkPlace automatically selects either the en-tire expression, or the part containing the insertion pointwhich is enclosed between a combination of text and binaryrelations, depending on the operation you chose. Here aresome examples that illustrate the various possibilities.

    An Equation Place the insertion point anywhere withinthe equation x + 3x = 1 and from the Maple menu

    3

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    3/31

    choose Solve + Exact. In this case, Scientic Work-Place selected the entire expression. The solutionis not equal to the original expression, so ScienticWorkPlace does not make it part of the original equa-tion:

    2x + 3x = 1, Solution is :

    x = 15

    Now place the insertion point in the left hand side ofthe equation and from the Maple menu choose Evalu-

    ate.2x + 3x = 5x = 1

    This time, Scientic WorkPlace selected only the lefthand side of the equation for evaluation. Notice toothat since the result of the evaluation was equal tothe original expression, the result was placed next tothe expression, preceded by an equals sign. The in-sertion point is placed at the right end of the resultso that you can select another operation to apply tothe result without moving the insertion point.

    Selecting Expressions for Operations

    If you want to restrict the computation to a particu-lar selection, or override Scientic WorkPlace's automaticchoice, you can use a selection. The next few examplesillustrate this feature. There are two options.

    Operating on a Selection Use the mouse or the shiftand rrow keys to select (x + y)5 in the expression

    (x + y)5

    7x 13y3 + sin 2x, from the Maple menuchoose Expand.

    (x + y)5

    7x 13y3 + sin 2x : x5 + 5x4y + 10x3y2 +10y3x2 + 5xy4 + y5

    Scientic WorkPlace puts the answer to the right of thewhole expression, following a colon (:). In general, ci-entic WorkPlace assumes that the result of applyingan operation to a selection is not equal to the entireoriginal expression and so it places the result at theend of the mathematics, separated by something (inthis case a colon) in text.

    Replacing a Selection Scientic WorkPlace will let youreplace part of an expression by the result of a com-putation on that part. Suppose you want to replace(x2y)2 in the expression x 2y)2(7x 13y)(x2 + 1)by its expansion. Select (x

    2y)2 in left(x

    2y2(7x

    13y)(x2 + 1) and hold down the ctrl key (Windows)or the cmd key (Mac) while choosing Expand from theMaple menu.

    (x 2y)2 (7x 13y)(x2 + 1)The eect is that (x 2y)2 is replaced by x2 4xy + 4y2.

    It has no parentheses around it, but since it remainsselected, you can simply click on () to add the neededparentheses. Now return the expression to its originalform by selecting

    x2 4xy + 4y2 ; holding down the

    ctrl/cmd key, and from the Maple menu choosingFactor. Here are some more examples.

    1. Select the denominator in 2x2+2x+1

    (x+1)(x1) , hold down thectrl/cmd key, and from the aple menu choose Ex-pand. Now undo what you just did by doing the ap-propriate operations.

    2. 2x2+2x+1

    (x+1)(x1)

    3. Select 2x2+ 2x in the numerator ofq

    2x2+2x+1(x+1)(x1) , hold

    down the ctrl/cmd key, and from the Maple menuchoose Factor.

    4.q

    2x(x+1)+1(x+1)(x1)

    5. Select 7891011 in the denominator of 52801234567891011

    and factor it, replacing 7891011 by the result. Nowreplace the numerator by its factored form.

    6. 253511

    123456325371233

    This \computing in place", that is, holding downthe ctrl/cmd key while performing operations from theMaple menu on a selection, is a key feature of ScienticWorkPlace. It provides a very convenient way to manipu-late expressions into the form desired.

    It is even possible to force Scientic WorkPlace towork with text. Try selecting 7 and from the Maple menuchoosing Evaluate.

    A Keyboard Shortcut for Evaluate

    Pressing ctrl/cmd + e acts the same as choosing Evalu-ate from the Maple menu. (There are some exceptions.)This is generally easier than choosing Maple and thenchoosing Evaluate with the mouse.

    Stopping a Computation

    Most computations are done more or less instantaneously,but there are some that take several minutes to complete.Occasionally it is convenient to be able to have Maplestop computing and return control to Scientic WorkPlace.This is accomplished by choosing ctrl + break (Win-dows) or cmd + . (Mac) after a computation has begun.Try it out by applying Factor to 291 + 3. Maple will actu-ally factor this in two or three minutes, but you can stopthe computation if you wish.

    291 + 3 = 97 317 1589 80621 71463 5064708073

    The Settings Menu

    The number of digits used in numerical computations andthe display of numerical results are controlled by choicesfrom the Settings menu. From the Maple menu chooseSettings. The Engine Parameters page shows the settingsthat you can make. We concern ourselves only with therst three now. They have to do only with computations

    4

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    4/31

    using oating point arithmetic, that is, with numbers with

    decimals in them. Their settings do not aect computa-tion or display of integer and rational number arithmetic.The rst choice, Digits Used in Computations, is self ex-planatory. You can choose any integer up to 1000. If alarge number is chosen, computations may be signicantlyslower. You can try various settings later on numericalintegration and the like to see just how speed is aected.

    Digits Used in Display is simply the number of digits

    put on the screen. This setting does not aect accuracy incomputations. Nonsignicant trailing zeros are suppressedand scientic notation is avoided where possible. If theThreshold for Scientic Notation is set to the positive in-teger n, then any decimal number whose absolute valuerounds to a number 10n will be displayed in scientic no-tation. What a number rounds to depends on the numberof display digits. The program insures that the scienticnotation threshold cannot exceed the number of displaydigits. For example, when Digits Used in Display = 5 anysetting of the scientic notation threshold greater than 5is equivalent to Threshold for Scientic Notation = 5.

    In the examples below, put Digits Used in Computation

    = 10, igits Used in Display = 5, and Threshold for ScienticNotation = 4 Evaluate the following expressions, and see ifthese evaluations agree with what you think they shouldbe.

    1. 1:2345 = 1: 2345

    2. 1:23454 = 1: 2345

    3. 1:23455 = 1: 2346

    4. 12:3456 = 12: 346

    5. 1234:56 = 1234: 6

    6. 12345:6 = 12346:

    7. 12345:0 103 = 1: 2345 107

    8. 999994 1:0 = 9: 9999 105

    9. 999995 1:0 = 1: 0 106

    10. 999996:0 = 1: 0 106

    11. 999986:0 = 9: 9999 105

    12. 999995:9 102

    13. 999994:

    102

    14. 999995:0 1012

    15. 888895 1:016. 889995 1:017. 899995 1:018. 123 :0119. 123 :0001

    20. 123 :0000121. 123 :00000122. 12 :0000123. 12 :000001

    The Series Order for ODE Solutions item species thenumber of terms you get in a series solution of a dierential

    equation.The Error Level setting determines what messages aregiven to you when making a computation. The higher thelevel the more messages you get. Here are the meaningsof the various error levels:

    Level Meaning0 No messages under any circumstances1 Beep if there is an error2 Display errors in a dialog box3 Display memory use in status area4 Show all Maple commands sent in the

    status area5 3 and 4

    6 Show memory use in dialog boxes7 Show all Maple commands sent indialog boxes

    8 6 and 7

    Working with Expressions and Functions

    The Slash Operator (/)

    Interpreting the slash operator in the absence of adequateparentheses is an entertaining pastime. There is a specialkeyboard command to obtain Scientic WorkPlace's inter-pretation of an expression. It is ctrl/cmd + ?. Applythis command to the following expressions, seeing if youcan predict each interpretation. Of course, possible ambi-guities can always be eliminated by adding parentheses.

    a=bc = abc

    a=b + c = ab + ca=b(c + d) = ab (c + d)

    (a + b)=(c + d) = a+b(c+d)Note the dierence in the treatment of = in the next

    two examples:sin =2 = sin 2sin a= cos b = sinacos ba=bc sin = abc sin sin =(a + b)(c + d) = sin (a+b) (c + d)

    a=bc = abc2=3(4) = 2342=(3)4 = 234sin =2(3) = sin 2 3 = 1sin =(2)3 = sin 23 =

    12

    sin =(2)(3)sin =(2 3)sin 2

    5

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    5/31

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    6/31

    15. j40j The vertical bars here come from the keyboard,or from the ()[] dialog box. They are equivalent. Thevertical bar on the leq panel may not be used todenote absolute value.

    16. abs(40) To enter abs, you may use the custom namefeature of the sin cos dialog box.

    17. k69:0k You should get a syntax error here. Mapleexpects a matrix or vector of length at least two inside

    kk. Try evaluating k(3; 4)k. The double bars on the panel may not be used for this purpose.

    18.52

    19.

    10025

    20. Try Check Equality on a2 b2 = (a b) (a + b), on

    256 = 256:0 and on a = b. The fact that 256 = 256:0is a little surprising, but that is Maple's choice.

    More Operations

    This section illustrates the use of some of the other opera-

    tions available through Scientic WorkPlace. First, simpli-cations and expansions of various trigonometric expres-sions are illustrated.

    1. sin 2x + cos 2x

    From the Maple menu choose Simplify. Also chooseCombine + Trig Functions.

    2. sin2

    Here, choose Expand, and apply Combine + Trig Func-tions to the result. Do the same to the next two.On some of these, execute the commands \in place".

    That is, select the expression, and hold down thectrl/cmd key while choosing the menu com-mand. Don't forget this facility.

    3. sin(a + b)

    4. tan(a + b)

    5. sin(2a + 3a)

    On this last one, most any command exceptExpand will yield sin(5a): Try them all. Nowchoose Expand, and to the result, apply ombine+ Trig Functions.

    6. sin(2a + 3b)Apply Expand and on the result execute Com-bine + Trig Functions. The result of Expand maybe too long to go on one line. You canview the result by scrolling horizontally.ctrl/cmd + space breaks but keeps the ex-pression \as one" so that computations canbe made on it. Execute Expand on the fol-lowing two and Combine + Trig Functions on theresults.

    7. sinh(a + b)

    8. tanh(2a + b)

    Apply Evaluate and then Simplify to the follow-ing:

    9. (sin a)=(cos a)

    10. (sinh a)=(cosh a)

    Expressions involving powers, exponentials,and logarithms can be simplified and ex-panded using the commands Powers, Exponentials,and ogs under the Combine submenu item. Hereare some examples of these computations.

    11. exp a exp b

    Try Simplify and Combine + Exponentials.

    12. exp2a exp3b

    13. exp(2a + 3b)

    14. eaeb

    Apply Expand and then Combine + Exponentialson the result. implify does the same thing asCombine + Exponentials.

    15. exp(2a)

    16. ln2a

    Choose Expand and then Combine + Logs on theresult. Do the same to the next one.

    17. ln(6ab2)

    18. xa+2

    Choose Expand and then apply Combine + Powers.Do the same for the next one. Simplify doesthe same thing as Combine + Powers here.

    19. ax+ybx+z

    20. axbx (Maple doesn't seem to let you get thisinto the form ab)x.)

    21. exp(a2) + ln ab

    Some Special Operations and Commands

    We have been applying the various Maple command toexpressions, for example, Factor to x2

    y2. Many com-

    mands will operate entrywise on vectors and matrices ofexpressions. These commands include Evaluate, valuateNumerically, Combine, Simplify, Factor, and Expand. Applythese commands to the following matrices.

    1. (1; 2; 3; 4; 5; 6)

    2.

    ln e

    p16 3

    6 3p

    8 4

    7

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    7/31

    3.

    6! 22 3x + 2x

    ln a + ln b x3 y3 sin2 x + cos2 x

    4.

    22 4481 65

    mod3

    The results of a computation may be too long to ton a line on the screen. \Allow breaks" have been pro-grammed in so that such results have line breaks in themif needed. (Such breaks cannot occur in expressions such

    as matrices, vectors, fractions, and so on.) Evaluate thefollowing to see examples of this.

    1.P50i=0 xi

    2. 50!

    Also Shift + Space may be used to introduce possibleline breaks in mathematical expressions. Occasionally, anexpression such as a matrix is just too big to t on a line.But you may use the horizontal scroll bar at the bottomof the screen to see the entire result.

    Constants

    Scientic WorkPlace recognizes various constants. Theseinclude e;; and i: Here are a few illustrations.

    Put the insertion point after e and choose EvaluateNumerically from the Maple menu. Alternatively, you couldselect the e before applying the operation. Now do thesame for and i2. Note the behavior when choosing Eval-uate and when choosing Evaluate Numerically on the fol-lowing items.

    1. e

    2.

    3. i

    4. j1 + ij5. abs(1 + i)

    6. ex

    7. eiie

    8.P3n=1 i

    3

    9.P3i=1 i

    3

    Look carefully at the last example. It shows that idoes not always mean sqrt1, and illustrates how Scien-tic WorkPlace must decide whether i is really

    p1 orjust another variable.

    Polynomials

    Here we want to illustrate the usual operations on poly-nomials. The special commands for polynomials are inthe menu gotten by choosing Polynomials from the Maplemenu. The choices there are Divide, Partial Fractions,Roots, Sort, and Companion Matrix. Divide applied to aquotient of polynomials f(x)=g(x) with integer coecientsgives q(x)+r(x)=g(x); where the deg r(x) < deg g(x): Par-tial Fractions is also an item on the |sf Calculus menusince a typical application is to integration. Roots ndsthe roots of a polynomial with complex coecients, andSort puts the terms of a polynomial in decreasing orderof powers. Companion Matrix simply gives the companionmatrix of a polynomial.

    There are many other commands available to apply topolynomials, such as Simplify, Factor, Expand, and so on, aswell as the usual operations of addition and multiplication.

    1. Apply Evaluate to gcd(5(x2 1); 10x 10)2. Apply Expand, and then Factor the result.

    5 (x + 1)3 (x

    1)2

    3. Factor the following expression and then Expand theresult. 5 x5 + 5x4 10x3 10x2 + 5x + 5

    4. Try applying Combine Powers, and Evaluate, and im-plify to 5x5 + 5x410x310x2 + 5x + 5 + 4x63x5 +x2 6

    5. Apply Partial Fractions to 2x2+2x1

    (x+1)(x1)

    6. Apply Partial Fractions to 2x2+2x1

    (x+1)2(x2x1)2

    7. Apply Simplify to x+2x+1 +3xx1

    8. Apply Factor to x+2x+1 + 3xx1 . Note that factor andsimplify are the same in this context.

    9. Apply Expand to x+2x+1 +3xx1

    10. Apply Partial Fractions to x+2x+1 +3xx1

    The feature of computing in place is very handy in ma-nipulating polynomials. For example, applying Sim-

    plify to x+2x+1 +3xx1 gives 2

    2x2+2x1(x+1)(x1) , and if you want

    the denominator to be multiplied out, just select itand choose Expand while holding down the ctrl/cmdkey.

    11. Apply Polynomials + Divide to 6x3

    +5x2

    x+1x+3

    12. Apply Polynomials + Divide to (6x3+5x2x+1)=(x+3)

    13. Apply Polynomials + Roots to x3 + 3x2 + 3x + 1

    Note that multiplicities are given. Compare with thefollowing.

    14. Apply Polynomials + Roots to x5+5x410x310x2+5x + 5

    8

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    8/31

    15. Apply Polynomials + Roots to ax2 + bx + c

    16. Apply Polynomials + Roots to x3 + 3x + 1

    Maple uses the usual formulas for nding roots ofpolynomials of degree 3 or less. If you want the rootsof this polynomial in simpler form, change one of thecoecients to a decimal and Maple will evaluate theroots numerically. Compare with the following exam-ple.

    17. Apply Polynomials + Roots to x3 + 3:0x + 1

    18. Apply Polynomials + Roots to x4 2x 3Maple uses the formula to nd the roots of this fourthdegree polynomial, and displays these roots in a col-umn matrix. But Maple will not nd the roots sym-bolically of just any old fourth degree polynomial. Seewhat happens in the next example.

    19. Apply Polynomials + Roots to x4 + 2x3 + x2 + 3x 5 Here Maple in eect just returns the polynomial.Change one of the coecients to decimal form. Itthen will give the four roots as a column matrix.

    20. Apply Polynomials + Roots to x5 + 7x2 + x + 1

    21. Apply Polynomials + Roots to x5 +(7+i)x2 +x + + i

    22. Apply Polynomials + Roots to x5 + 7x2 + 3ix + e

    23. Apply Polynomials + Companion Matrix to x3 + ax2 +bx + c

    Maple insists on a monic polynomial.

    Limits

    You can take limits. The function lim is one of the func-

    tions that can be chosen when you click the sin cos icon.You can also get it by typing \lim" while in mathematicsmode. To evaluate a limit, choose Evaluate from the Maplemenu or ctrl/cmd + E. Evaluate the following limits.

    1. limx!0 sinxx : 1

    2. limx!1px2+3x+1p16x2+x+2

    3. limx!0+ xjxj

    4. limx!0 x= jxj5. limy!0

    y

    jyjlimx!1

    1

    x

    6. limx!0 1x arccos x

    7. (x + 1)2 + limx!0 sinxx + (a + by)2

    Dierentiation

    Scientic WorkPlace recognizesvarious notations for dierentiation, including the formsddx ;dn

    dx ; Dx:Dxy; Dxsyt;@@x ; and

    @n

    @xsyt ; where s + t = n:Also note in the examples below that parentheses, brack-ets, and braces are equally acceptable. Notice how Scien-tic WorkPlace handles the ill-formed expressions in thelist below.

    Place the insertion point anywhere in the expressionddx(x

    2). Choose Evaluate from the Maple menu (or choosectrl/cmd + E. Now do the same for the following ex-pressions.

    1. dx2

    dx : 2x

    2. ddx

    x2 : 2x

    3. Dxx2 = 2x

    4. Dx[x2]

    5. Dx(x2)

    6. @@xx2

    7. @@xfx2g

    8. @2

    @x2 x2 + 3x : 2 + 3x

    9. @2

    @x2 ((x2 + 3x)

    10. @2

    @x2 (x2 + 3x

    11. @2

    @x2x2 + 3x)

    12. @2

    @x2 (x2 + 3x]

    13. @@x@yx2y3 : 6xy2

    Scientic WorkPlace will do implicit derivatives also.mplicit Dierentiation is under the Calculus menu and willbe discussed in connection with that menu.

    Indenite Integration

    Next we illustrate computing indenite integrals. A basicproblem for Scientic WorkPlace here is to decide what tointegrate and to choose the variable of integration.

    Place the insertion point anywhere in the expression

    R(ax2 + bx+c)dx. From the maple menu, choose Evaluate,

    or choose ctrl/cmd + E. In this case, the expression tobe integrated is syntactically correct. Scientic WorkPlacenot only allows any syntactically correct expression in theintegrand, but also is forgiving. For example, evaluate thefollowing expressions.

    1.R

    1xdx

    2.Rdxx

    3.R

    ax2 + bx + cdx

    9

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    9/31

    4.R

    ax2

    5.R

    1xn

    In these three examples, Scientic WorkPlace had tochoose a variable of integration, and x was chosen.If a variable of integration is not specied, ScienticWorkPlace will choose a variable of integration andthe choice generally is the last symbol appearing. Thefollowing integrals illustrate this.

    6.R

    ax

    7.R

    xb

    8.R

    xadx

    9.R

    1x2+y2

    10.Rx2

    x2+y2

    If the insertion point is placed within a mathemati-cal expression, trl/cmd + ? gives Scientic Work-Place's interpretation of that expression. Try this onthe expressions above.

    In choosing a variable of integration for you when theintegrand contains no dened expressions, ScienticWorkPlace generally picks the last variable found. Inquotients, it picks the last variable in the numerator.If there is no variable in the numerator, as in the ex-ample int 1x2+y2 , it then looks at the denominator andpicks the last variable there. Thus the results above.Of course, you can avoid having Scientic WorkPlacepick a variable of integration by specifying it your-self with the usual dx notation. Finally, notice whathappens on the next three.

    11. Rf12.

    Rf(x)

    13.R

    f(x)dx

    The last three integrals should really be no surprise.In the rst, f is treated just like x, and the complete ex-pression is

    Rf df. In the second, since f is not dened

    as a function, Scientic WorkPlace interprets f(x) as theproduct f x. It then chooses x as the variable of inte-gration, and the complete expression is intf xdx. Thethird expression is treated the same as the second. If fhas been dened as a function, as we will learn how to do

    later, thenR

    f(x)dx will be the integral of the expressionf(x) with respect to the variable x, as it should be.

    Sequences of Operations

    Here are some examples which shows how you might per-form sequences of computations, exploring as you go.

    Sequences of Computations Place the insertion pointwithin the expression

    Reax cos bxdx and choose Evalu-

    ate from the aple menu. Without moving the insertion

    point, choose Factor. The sequence of expressions isReax cos bxdx = aa2+b2 e

    ax cos bx + ba2+b2 eax sin bx =

    (eax) a cos bx+b sin bxa2+b2 .

    Now place the insertion point in the expressionR2x cos bxdx and perform the following sequence of

    computations from the Maple menu: Evaluate, Sim-plify, Combine Trig Functions, and implify. The com-plete sequence of expressions you should see is as fol-lows.R

    2x cos bxdx =ln 2

    ln2 2+b22x ln 2

    ln2 2+b22x tan2 1

    2bx+21+x b

    ln2 2+b2tan 1

    2bx

    1+tan2 12bx

    =

    21+x ln2 cos2 12bx(ln2)2x+21+xb sin 1

    2bx cos 1

    2bx

    ln2 2+b2=

    12(ln2 2+b2)

    21+x ln2cos bx + 12(ln2 2+b2)

    21+x ln 2 fracln2ln2 2 + b22x + 1

    2(ln2 2+b2)21+xb sin bx =

    2x ln2 cos bx+b sin bxln2 2+b2

    Notice that the form of the nal result is the same asin the rst example. Here, you are experiencing thedierence between the way Maple handles exponen-tials and powers, and possibly the limitations on mem-

    ory when Maple and Scientic WorkPlace are runningtogether.

    These examples illustrate how you can interact withthe system to explore for the result you want. The inter-action is both smooth and natural. You might also exper-iment with other sequences of operations|it is possible toend up with ever larger expressions by choosing the wrongoperations.

    Denite Integrals

    To evaluate a denite integral, place the insertion point in

    the expression to be evaluated and from the Maple menu,choose Evaluate, or ctrl/cmd + E, or Evaluate Numeri-cally. Try the three choices on int10xdx.

    Evaluate the following denite integrals. Some ofthem may take Maple a little time to compute.

    1.R0

    sin xdx

    2.R10 ln xdx

    3.R10

    exdx

    4.R0

    x lnsin xdx

    5.R10 exdx

    6.R10

    ex2

    dx

    7.R11

    1x5 dx

    8.R10

    1x2 dx

    9.R11

    1x2 dx

    10.R10

    1x2 dx

    10

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    10/31

    11.R10dx

    (1+x)px

    12.R10

    cosxpx

    dx

    13.R10

    lnxdx1x

    14.R10

    lnxdx1x2

    15.

    R10x3

    ex1dx

    16.R10x13

    ex1dx

    Numerical Integration

    Numerical integration can be performed by selecting Eval-uate Numerically on the Maple menu. Try this on the ex-amples below. Some of them take a couple of minutes.

    1.R10

    ex2

    dx

    2.R10

    sin x3dx

    3. R10 sin3 100x5dx4.

    R40

    cos x log xdx

    5.R10 x

    :8p1 x4dx

    Innite Series

    Many expressions can be expanded in innite series bychoosing Series on the Maple menu with the expressionselected. A dialog box comes up with two choices to bemade, the number of terms in the expansion, and what toexpand in powers of. The default for the number of termsis 5. The Expand in Powers of box must be lled in.

    1. ex Expand in powers of x.

    2. e2x+3y Expand in powers of x 1.3. e2x+3y Expand in powers of y 2.4. x sin x Expand in powers of x.

    5. x sin x Expand in powers of y.

    6.p1x4x2 Expand in powers of x + 1.

    Substituting a Value into an Expression

    We currently accept these forms:exprjsupersub expr]supersub [expr]supersub exprjsupersub andexprjsub expr]sub [expr]sub exprjsubNote that the rst three forms in each list have \expr"

    surrounded by a \fence" from the Brackets dialog box, andthe left fence delimiter is the \null delimiter"; that is, anempty bracket. The null delimiter does not print, althoughit is visible on screen as a dotted vertical line.

    The sub and superscripts contain the substitutionsthat are to be made in the expression. If only a subscript

    is present, the expression is evaluated at those substitu-tions. If both are present, we get the expression with thesuperscript substitutions minus the expression with thesubscript substitutions. Apply Evaluate to the followingexamples:

    xy]x=5x=2

    xy]x=2(x + y)

    4ix+y=z

    xy]x=2;y=3

    xy]x=4;y=5x=2;y=3

    [xy]x=4;y=5x=2;y=3xyjx=4;y=5x=2;y=3R

    sin xdxx=1x=0R

    sin xdx10R

    sin xdxjx=1x=0Rsin xdxj10

    When the superscript and subscript are just numbers,the expression must contain only one variable, otherwiseScientic WorkPlace reports an error.

    Matrices

    Standard Operations

    Maple has a large linear algebra package that containsmany operations on matrices. Choosing Matrices from theMaple menu brings up a host of operations that can be per-formed on a single matrix. Scientic WorkPlace performsthe usual matrix addition, multiplication, and operationsbetween scalars and matrices. These are illustrated in thefollowing list.

    1. From the Maple menu, chooseEvaluate. 1 24 3

    +5 68 7

    .

    The result,

    6 8

    12 10

    , appears with square brackets

    around it. Scientic WorkPlace uses the same brack-ets for the result as appeared in the expression. Thisapplies to parentheses and brackets.

    2. Evaluate the expression a

    1 24 3

    + b

    5 68 7

    .

    Try various other Maple commands on this one, likeSimplify and xpand. Evaluate the following three ma-trix expressions.

    3.

    1 24 3

    5 68 7

    4.

    5 68 7

    2

    5.

    5 68 7

    1Evaluate this one numerically also.

    11

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    11/31

    6. Apply Factor to this matrix.

    5 68 7

    Such operations as Factor operate on each entry of thematrix.

    7. Apply Evaluate to the expression 5+

    1 24 3

    Notice

    how this is handled. The 5 is treated as 5 times the 22 identity matrix. This is convenient when evaluatingpolynomials at matrices, as in the following example.

    8.

    1 24 3

    2 5

    1 24 3

    2

    9. The exponential function is dened for matrices. Eval-

    uatet

    1 24 3

    . Of course, it's for expressions such

    as these that one needs to be able to denote a ma-trix by a symbol, that is, to make such denitions as

    A =

    1 24 3

    and then write etA. We will learn how

    to do this in the section on denitions.

    The Matrices Submenu

    The following examples illustrate using the commands inthe Matrices submenu. Apply the command indicated.

    1. Adjugate

    a bc d

    2. Concatenate

    a bc d

    1 2 34 5 6

    3. Characteristic Polynomial

    a bc d

    This operation chose the variable X for the polyno-

    mial. Its ritual for choosing the variable should neverconfuse that variable with a matrix entry. For exam-

    ple, nd the characteristic polynomial of

    xX y

    .

    Column Basis

    1 23 4

    4. Condition Number

    1 23 4

    5. Deniteness Tests

    1 23 4

    6. Determinant a b

    c d

    There is a function det available directly, either bytyping it in while in mathematics mode or by clickingon it in the list under sin cos. So one may also compute

    a determinant by applying Evaluate to det

    1 23 4

    ,

    for example. Try it. Now evaluate det

    0@ 1 a a

    2

    1 b b2

    1 c c2

    1A

    and factor the result.

    7. Try the matrix commands Eigenvectors and Eigenval-ues on the matrices

    cos sin sin cos

    and

    1 23 4

    . Try both Exact

    and Numeric when appropriate.

    8. The command Fill Matrix... allows easy entry of ma-trices of various special kinds. The menu that comesup is self explanatory. For example, to enter a 3 3identity matrix, choose Fill Matrix... , set Rows and

    Columns to 3, and choose Identity in the window ofthe menu. Experiment with this command. See whathappens when you choose a 56 matrix and Identity.The Band option requires that you enter a list like\a;b;c" with an odd number of entries. Entering thelists \0", \1", and \0; ; 1" will generate respectively,a zero matrix, an identity matrix, and a Jordan block.The Dened by function option allows you to dene afunction like f(i; j) = 1

    i+j1 , enter f in the box as thename of the function, and generate a Hilbert matrix.

    Fill Matrix... has another important function. If you

    have a matrix such as24

    1 2 3

    5 5 47 8 935

    and would like

    the lower right 2 2 corner to be the zero matrix,then select this corner of the matrix, and under FillMatrix... choose zero. Try it. The lower right corneris replaced by the 2 zero matrix. No new matrix iscreated|a replacement is made.

    There seems to be no way to insert a new matrix withFill Matrix... with alignment other than center align-ment for columns and center alignment for placementin text. But you can always change the alignments ofa matrix using the Scientic WorkPlace revise button.

    9. Fraction Free Gaussian Elimination

    a bc d

    10. Gaussian Elimination

    0@ 2 1 01 2 1

    0 1 2

    1A

    11. Choosing Hermitian Transpose on the Matrix menu hasthe obvious result. One may also get the Hermitiantranspose of a matrix by using the superscript H. Try

    it on

    i 2 + i

    4i 3 2iH

    12. Inverse0@ 2

    1 01 2 1

    0 1 21A You can also take the in-

    verse of a matrix A by evaluating 1. Try it.

    13. Jordan Form

    0@ 2 1 01 2 1

    0 1 2

    1A This produces a fac-

    torization of the matrix as P JP1where J is in Jor-dan form. This holds for the rational canonical formalso, and is illustrated below.

    12

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    12/31

    14. Minimum Polynomial

    a bc d

    As in the case of characteristic polynomials, the sys-tem nds a variable for the minimum polynomial. Youdo not have to specify it.

    15. Norm

    0@ 2 1 01 2 1

    0 1 2

    1AThere are other norms This

    one is the 2-norm.0@ 2 1 01 2 1

    0 1 2

    1A2

    gives the

    same norm. In the section on denitions, other normsof matrices are illustrated.

    16. Null Space Basis

    0@ 2 1 02 1 0

    0 1 2

    1A

    17. Orthogonality Test

    cos sin sin cos

    18. Permanent a bc d

    19. QR

    0@ 2 1 02 1 0

    0 1 2

    1A

    20. Rank

    0@ 2 1 02 1 0

    0 1 2

    1A

    21. Rational Canonical Form

    a bc d

    22. Row Reduced Echelon Form0@ 2

    1 0

    2 1 00 1 2

    1A

    23. Reshape

    0@ 2 1 02 1 0

    0 1 2

    1A Try this on matrices of var-

    ious shapes.

    24. Row Basis

    0@ 2 1 02 1 0

    0 1 2

    1A

    25. Singular Values

    1 23 4

    26. SVD produces a factorization of the form U DV whereD is the diagonal matrix of singular values and U andV are orthogonal matrices. This operation works onlyon matrices of numbers. Try it on the matrix above.

    27. Smith Normal Form

    1 23 4

    28. Trace

    a bc d

    29. Transpose

    a bc d

    You can also get the transpose of

    a matrix using a superscript T Evaluate

    a bc d

    T.

    Solving Systems of Equations

    Solve on the Maple menu gives solutions to equations andsystems of equations. There are four choices under the

    Solve menu: Exact Numeric, Integer, and Recursion.

    Solve Exact

    To solve 2x = 4, choose Solve + Exact. The solution ap-pears after the equation. Try it. Do the same for theequation y3 y 1 = 0.

    A system of equations is written by entering the equa-tions in an n 1 matrix, one equation to a row. Alterna-tively, a system of equations can be typed into a display,using the enter key to add additional equations. Whenwe have the same number of unknowns as equations, weput the insertion point anywhere in the system and choose

    Solve + Exact. The variables are found automatically. Trythe following examples.

    1. This is a 2 1 matrix. x2 + 3y2 = 7

    x2 2y2 = 22. This is a display.

    x + y 2z = 12x 4y + z = 0

    2y 3z = 1

    3.

    2x y = 1x + 3z = 4x y 3z = 3

    A system of linear equations can also be dealt with bysolving its matrix version. The last two examples abovecorrespond to the two matrix equations below. Use Solve+ Exact to solve these equations and compare the solutionswith those you obtained above.

    1.

    24 1 1 22 4 1

    0 2 3

    3524 xy

    z

    35 =

    24 101

    35

    2.24 2 1 0

    1 0 31 1 3

    3524 xyz

    35=

    24 143

    35

    There is no problem when the number of unknownsmatches the number of equations, but when there are moreunknowns than equations, Maple must be told which un-knowns to solve for. To solve the following equation, youmust specify the unknown. Put the insertion point any-where in the equation and choose Solve + Exact. A dialogbox comes up asking you to choose the variable(s) to solvefor. Solve rst for x and then for y.

    13

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    13/31

    ex = y+1y1Here is a system with 2 equations and 3 unknowns.

    Solve it for x and y, and then for x and z. To do it, justclick anywhere in the system, choose Solve + Exact and llout the dialog box with \x; y" or \; z".

    2x y = 1x + 3z = 4

    Solve the following two systems for various combina-tions of the unknowns.

    2x

    y2 = 1x + 3z = 4 When solving for x and y; or for y and

    z, the solution to this system is given in terms of the rootsof a quadratic.

    2x y = exx + 3z = 4

    The solution to the following system is given in termsof the roots of a cubic.

    2x y2 = 1x + 3z = 4

    y + z2 = 2

    The next system is the same, but with a oating pointnumber in it. In this case, only real solutions are returned.

    2x y2 = 1:0x + 3z = 4y + z2 = 2

    Solve Numeric

    Solve + Numeric is meant to be used only on special oc-casions.footnotet is used mainly on birthdays, weddings,Bar Mitzvahs, and occasions when equations involving ex-ponentials must be solved. If answers are desired in dec-imal form, put one of the coecients in the equations inoating point form and use Solve + Exact.

    Solve + Numeric is used primarily when solving (sys-tems of) transcendental equations. Solve + Numeric at-tempts to nd a single real solution, but may fail evenif solutions exit. The important feature is that you canrequire that variables take values in specied search inter-vals. Specifying appropriate search intervals may result ina successful calculation. Try these examples:

    1. 10x = ex Use Solve + Exact and note what happens.Now do the next two using Solve + Numeric.

    2. 10x = ex; x 2 (1;1) Note the red comma and noimbedded spaces.

    3. Displays can also be used for equations with searchintervals.

    10x = ex

    x 2 (0; 1)

    4.

    0@ x

    2 + y2 = 5x2 y2 = 1

    x 2 (0; 4)

    1A Use Solve + Numeric. Note that if

    (x; y) is a solution, then so is (x;y).

    5.

    0BB@

    x2 + y2 = 5x2 y2 = 1

    x 2 (0; 4)y 2 (0;1)

    1CCA Use Solve + Numeric.

    Solve Integer

    Solve + Integer nds integer solutions to equations andsystems of equations. Use Solve + Integer on the followingexamples.

    1. 3x + 4y = 10

    2.3x + 2y = 53x z = 1

    Solve Recursion

    Solve + Recursion nds solutions to a recursion or a systemof recursions. Try the following examples.

    1. y(n + 2) + 3y(n + 1) + 2y(n) = 0

    2.

    y(n + 2) + 3y(n + 1) + 2y(n) = 0y(0) = 2y(1) = 1

    3.

    y(n + 1) + z(n) = n + 2n+1

    z(n + 1) y(n) = n + 3 2ny(1) = 1z(1) = 2

    Modular Arithmetic

    The Integers modulo m

    The basic computation Scientic WorkPlace does here is toevaluate alimfuncmodm where a is and integer and m is apositive integer. Place the insertion point in the expressionand apply Evaluate. The answer is the least non-negativeresidue. For example 34 mod 4 = 2, and 69mod13 = 9.

    You can also evaluate a1 mod m if a and m arerelatively prime. In particular, you can always evaluatea1 modp where

    isaprimeand

    aisnotamultipleofp.Forexample231limfuncmod3 = 2,and hence 232 mod 3 = 1. So you can solve congruencesax b mod m by calculating a1b mod : Solving the con-gruence 25x 8 mod13, we get 25

    1

    8limfuncmod13 =5. (Note that applying Solve + Exact to 25x 8 limfuncmod13 leads to a parsing error. Scientic Work-Place does not understand the notation directly.) In-deed, 25 (5) mod13 = 8. You can solve systems of con-gruences (if the moduli are relatively prime in pairs) bysolving them two at a time and thus reducing to one con-gruence. To solve the system

    x 45 mod237x 19 mod419

    14

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    14/31

    we have x = 45 + 237k, and substituting into the secondcongruence gives 45 + 237k 19 mod419. Thus 237k 19 45 mod19, and k 2371(19 45)mod419 = 60.Hence x = 45 + 237 60 = 14265. The solution is uniquemodulo (237 419) = 99303. Solve the following systemof congruences and check your answer.

    x 36 mod111x 18 mod237x 120 mod 419.

    To calculate powers modulo m; write anmod m andevaluate. You can dene things rst if you wish. Forexample, make thedenitions = 2789596378267275; n = 3848590389047349,and m = 2838490563537459. Calculate nmod m and27895963782672753848590389047349 mod 2838490563537459.These calculations are done rather quickly.

    Matrices Modulo m

    The mod function also works with matrices. Here are someexamples.

    1.

    5 8 129 4 34

    mod 3 =

    2 2 00 1 1

    2.

    0@ 3 7 55 4 8

    2 0 5

    1A1

    mod11 =

    0@ 9 9 32 5 1

    3 3 10

    1A

    3.

    0@ 3 7 55 4 8

    2 0 5

    1A

    0@ 9 9 32 5 1

    3 3 10

    1A mod 11 =

    0

    @1 0 00 1 0

    0 0 1

    1

    ANote that the rst operates entry-wise. In the sec-

    ond, the matrix inverse is taken, operating mod 11. In thethird the left side is multiplied out and the result is givenmod 11.

    Polynomials Modulo m

    The mod function can also be combined with polyno-mials. The expression p(x) mod5 returns the polyno-mial p(x) with its coecients reduced mod 5: For example8x2+ 42x31mod5 = 3x2+ 2x + 4. Evaluate reduces eachof the coecients modulo 5. Notice that parentheses were

    not required around the polynomial.

    1.

    8x2 + 42x 31 (13x 23) mod7. If you apply Ex-pand to this expression, you get 6x3 + 5x2 + 3x +6. If you apply Evaluate, you get

    x2 + 4

    (6x + 5)

    To get the latter multiplied out mod7, expandx2 + 4

    (6x + 5), getting 6x3 + 5x2 + 24x + 20, and

    reduce this mod 7. Of course, you could have mul-tiplied

    8x2 + 42x 31 (13x 23) out rst by using

    the Maple command Expand, and then reduced mod 7.But the simplest thing to do is to apply Expand.

    2. Apply Factor to 6x3 + 5x2 + 3x + 6mod 7

    3. Evaluate the following expression and apply Factorto the result, operating mod 7.

    9x2 + 39x 29 +

    23x2 + 13x 23

    Polynomials Modulo Polynomials

    Two polynomials f(x) and g(x) are congruent modulo apolynomial q(x) if and only if f(x)

    g(x) is a multiple of

    q(x), in which case we write

    f(x) g(x) (mod q(x)) .

    Evaluating g(x)mod q(x) gives a polynomial of minimaldegree that is congruent to g(x) modulo q(x). Evaluatethe next two expressions.and apply Polynomial + Divide tothe third one.

    1. x3 + 3x2 + 3x + 1mod x + 1

    2. x5 4x2 + 3x 1mod x3 x2 + x 13. x

    54x2+3x1x3

    x2

    +x1

    Denitions

    If you choose Dene from the Maple menu, the submenuthat comes up has seven items: New Denition, Undene,Show Denitions, Clear Denitions, Save Denitions, RestoreDenitions, and Dene Maple Name. Here is how theywork.

    New Denition, Undene, Show Denitions, andClear Denitions

    There are two basic kinds of new denitions:

    1. Dening a symbol a to be an expression, such as x2+2,

    or a matrix such as

    1 23 4

    , or a vector, and so on;

    2. Dening a function f using an expression, for examplef(x) = x2 +2. Now a and f are mathematical objectsof dierent kinds, and as such have dierent behaviorand accept dierent operations on them.

    To make a denition, such as p = ax2 + bx + c, putthe insertion point anywhere in the equation, or select theexpression, and choose New Denition from the Dene sub-

    menu. This makes the assignment, and from then on, prepresents the expression ax2 + bx + c. It is not a func-tion, and in particular p(2) is not 4a + 2b + c, but 2p =

    2ax2+2bx+2c . On the other hand,R

    pdx = ax3

    3 +bx2

    2 +cx,

    and dpdx

    = 2ax + b.

    To use a symbol, say A, for the matrix

    a bc d

    ,

    click anywhere in the equation A =

    a bc d

    (or se-

    lect the whole thing if you prefer), and choose Dene

    15

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    15/31

    + New Denition. Then one can operate on A as withany matrix. For example, make the denition and thencompute A2, 5A, and A1, using Evaluate or ctrl/cmd

    + e. The results will be 2 =

    a2 + bc ab + bdca + dc bc + d2

    ,

    5A =

    5a 5b5c 5d

    , and A1 =

    dadbc badbc cadbc aadbc

    .

    The menu items Undene, Show Denitions, and ClearDenitions are self explanatory. Show Denitions exhibits

    all denitions in force. Clear Denitions clears all deni-tions that have been made. To clear particular denition,put the cursor anywhere in the dening expression andchoose Undene. Alternately, select the symbol denedand choose Undene. The symbol does not have to be inthe dening expression. For example if a has been de-ned by a = 2x + 4, then selecting any \a" anywhere, intext or in mathematics, and choosing Undene clears thedenition of a.

    Below are some more examples for you to try. Beforeyou start, Clear Denitions. It is easy to forget that somesymbol has been dened to be some expression, and if thatsymbol is used later, you can get surprising results. For

    example, if you made the denition a = x2, forgot aboutit, and later computed

    Rasds, expecting to get as

    2

    2 , youare in for a surprise. In some complicated computation,the error may not be apparent. So choose Clear Denitionsnow.

    Make the denitions p = ax2 + bx + c, q = 4y2 +

    3xy + 2, and A =

    1 x + y4 3

    . Evaluate the following

    expressions.

    1. p + q

    2. pq

    3. 3p + 4q

    4. p=(x + 1) Apply Polynomials + Divide to this one andthe next.

    5. q=(y2 + 1)

    6. A2

    7. pA

    8.R

    pdx

    9. dpdx

    10.R

    p

    11. Dx(pq)

    12.R

    pqdy

    13.R R

    pqdydxp

    14. qmod2

    If the integrand contains dened expressions, and novariable of integration is specied, the choice of that vari-able is made by Maple, and in ambiguous situations theresults can be unpredictable. Rework the last two exam-ples above after making the denitions a = x + y, andb = x + y.

    If the insertion point is placed within a mathematicalexpression, ctrl/cmd + ? gives Scientic WorkPlace'sinterpretation of that expression. Try this on the expres-

    sions above and on the following expressions. Note thatwhen the integrand contains dened expressions and novariable of integration is specied, the variable of inte-gration is shown as ?, indicating that Scientic WorkPlacecannot determine it. \?" is also used in sums and productswhen the index is not specied and dened expressions arepresent. Compare

    P3x=1 a with

    P31 a using ctrl/cmd +

    ?. Also, perform the integrations indicated, and note thechoice made by Maple in the ambiguous cases.

    1.R

    xa

    2.R

    xadx

    3.R

    1x2+y2

    4.Rx2

    x2+y2

    It is legitimate to dene expressions in terms of otherexpressions. For example, one can dene r = 3p cq ands = nr + dpdx .

    Now make the denitions r = 3pcq, s = nr+ dpdx

    , a =2x+ 3y and = ax and perform the following calculationson them. Remember that p and q have previously beendened as p = ax2 + bx + c and q= 4y2 + 3xy + 2.

    1. r + cq

    2.R

    (s nr)dx3. a

    4. dadx

    To dene the function f whose value at x is ax2 +bx + c, write f(x) = ax2 + bx + c, put the insertion pointanywhere in the equation and choose New Denitions fromthe submenu Dene. Now the symbol

    representsthefunctionsodefined; andbehaveslikeafunctio

    f(y)=ay2+by+c denes the same function. The symbolused for the function argument in making the denitiondoes not matter. You can even use a previously denedsymbol or the symbol f itself. Here are two examples.Dene the functions g and h and then evaluate them at t.Clear Denitions before you start.

    1. g(x) = x sin x

    2. Evaluate g(t)

    3. h(x) = x2

    16

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    16/31

    4. Evaluate h(t)

    The denition of a function f may be undone by high-lighting any `f" anywhere and choosing Undene. Alter-nately, you can put the insertion point in the deningequation and choose Undene. lear Denitions of courseundenes everything, functions and expressions.

    If you choose Show Denitions from the Dene sub-menu, a window comes up showing the denitions in force,

    both of expressions, or assignments, and of functions. Inthe case of assignments, we show the denition that Mapleactually made using full evaluation, rather than the de-nition we sent to Maple. In the case of functions we showthe denition we sent to Maple, rather than the denitionMaple made.

    If a dierential equation has been solved numerically,the name of the function constructed appears in the ShowDenitions window, with the indication that it is the re-sult of a numerical process. See the section on dierentialequations.

    If g and h are previously dened functions, then thefollowing equations are examples of legitimate ones for

    making denitions. Each time you redene f, the newdenition replaces the old one.

    1. Dene + New Denition f(x) = 2g(x)

    2. Evaluate f(t)

    3. Dene + New Denition f(x) = g(x) + h(x)

    4. Evaluate f(t)

    5. Dene + New Denition f(x) = g(x) h(x)6. Evaluate f(t)

    7. Dene + New Denition f(x) = g(x)h(x)

    8. Evaluate f(t)

    9. Dene + New Denition f(x) = g(x)=h(x)

    10. Evaluate f(t)

    11. Dene + New Denition f(x) = (g(x))2

    12. Evaluate f(t)

    13. Dene + New Denition f(x) = eg(x)

    14. Evaluate f(t)

    15. Dene + New Denition f(x) = g(x)h(x)

    16. Evaluate f(t)

    17. Dene + New Denition f(x) = g(h(x))

    18. Evaluate f(t)

    The standard operations, such as integration and dif-ferentiation, are available for functions in the follow-ing ways:

    19.R

    f(x)dx

    20. ddxf(x)

    21. Dxf(x)

    22. df(x)dx

    23. f0(x)

    What is really happening is that we are operating on

    expressions, not functions. That is, we always use f(x),or f(y), and so on, but never f alone. We have not imple-mented an algebra of functions.

    Note also (as illustrated by the last example above)that \prime" has been implemented as the dierential op-erator on functions. While we are free to use z0 = x + yas the name of an expression, we are not allowed to use z0

    as the name of a function to be dened. When f has beendened as the name of a function, f0(x) is its derivative atx and f00(2) is its second derivative evaluated at 2.

    Now make the denitions f(x) = x2 + 2x + c, andg (x) = xy c, and do the following calculations.

    1. f(0)

    2. f0(1)

    3. g00(t)

    4. f(y)

    5. f(g(0))

    6. f(2) g(c)7. f(g(x))

    8. Dxf(g(x))

    9.R10

    f(x)dx

    10.R10

    f(z)dz

    11.R10

    f(c)dc

    12. Dxf(x)

    13.R

    Dxf(x)dx

    14. DxR

    f(x)dx

    15. f0(s)

    16. f0(g(x))Here are some additional features involving Dene.

    17. Get series expansions for a and f(x) after making thedenitions a = e2x+3y and f(x) = x sin x.

    18. Polynomial functions can be evaluated at matrices.

    Dene A =

    1 23 4

    and p(x) = x2 5x 2: Can

    you explain the result when you evaluate (A)? Be surethat you press ctrl/cmd + e twice.

    17

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    17/31

    19. In dealing with matrix equations, the matrices maycontain parameters, have more than one column andmay be dened expressions. To illustrate this, dene

    A =

    1 23 4

    , b =

    2 1 46 2 10

    and from the Solve

    submenu apply Exact to the following equations.

    20. AX = b

    Now dene A = s 23 4 and b =

    26 and apply

    Solve + Exact to

    21. AX = b

    For some reason Maple will allow a multicolumn bor an A with parameters, but not both in the sameequation.

    22. Clear denitions and dene f(x; y) = 23x2y +456xy +512mod7. Evaluate

    23. f(x; y)

    24. f(12; 2c)

    25. Dene + New Denition f(t) = 3t2+ 5t+6mod x2 + 1.Evaluate

    26. f(x2 + x + 2)

    27. f(x2 + 1). Warning: Do not dene f(x) = 3x2 +5x +6mod x2 + 1 and evaluate f(some polynomial inx). This will change the modulus and give nonsenseanswers.

    Denitions with Deferred Evaluation

    Several users have complained about Maple denitions,

    which in SWP2.01 uses the Maple default of full evalu-ation. The process of full evaluation applies the resultsof previous denitions to candidates for new denitions.Thus, if the denition a = 1 is followed by the denitionx = a , then x has a value of 1 under full evaluation .Subsequent changes to the value of a do not aect x: Un-der deferred evaluation, any changes to a will change thevalue of x: The process of deferred evaluation is now usedin Scientic WorkPlace.

    In particular, recursive denitions are no longer al-lowed.

    Remembering Solutions

    Solving an equation or system of equations leads to solu-tions, but the resulting equations are not denitions. Inorder to use the solutions, select an equation and applyDene + New Denition.

    For example, recall the system

    x + y 2z = 12x 4y + z = 0

    2y 3z = 1

    whose exact solution is

    z = 54 ; y =118 ; x =

    178

    . To use

    x, y, and z, select the equation x = 178 and apply Dene+ New Denition; select the equation y = 118 and applyDene + New Denition; and select the equation z = 5

    4and apply Dene + New Denition. This process can bedone conveniently with a mouse by selecting an equationand clicking the dene icon or from the Dene submenuchoosing New Denition.

    Save Denitions & Restore Denitions

    Choosing Save Denitions from the Maple menu has theeect of storing all the currently active denitions in theworking copy of the current document, and when the doc-ument is saved, the denitions are saved with it. Re-store Denitions is just the reverse|it takes any deni-tions stored with the current document and makes themcurrently active. Note that each invocation of Save Den-itions overwrites any denitions that may have been pre-viously saved, so if you want to add some denitions tothose already saved, you must choose Restore Denitionsbefore Save Denitions. Denitions are saved and restored

    in the order in which they were made.The fact that active denitions are currently associ-ated with the Maple session rather than a specic doc-ument is sometimes a source of confusion. The Maplesession lasts as long as we are continuously in cienticWorkPlace, even though we may edit a number of dif-ferent documents during the session. To see this, makeseveral denitions, choose Show Denitions to verify thatthey are in eect, and then open a new document. ChooseShow Denitions again and note that the same denitionsare still in eect. This can be a convenience if you areworking on related documents and want to use these def-initions, but if not, Clear Denitions will get rid of them,

    and Restore Denitions will activate any denitions storedwith the new document.

    The Denition Options on the Settings Menu speci-es the default behavior of saving and restoring denitionswhen saving and opening documents.

    Functions of Several Variables

    Functions of several variables are dened by writing anequation such as (x; y; z) = ax + y2 + 2z, or g(x; y) =2x + sin3xy for example, clicking in the equation andchoosing New Denition. Just as in the case of functionsof one variable, we always operate on expressions gotten

    by evaluating the function at a point.

    Row and Column Arguments

    If we want a number of values of a function, it is conve-nient to be able to pass all the data to Maple in an arrayand have it return an array of the same dimensions con-taining the function values. We have implemented this forarrays which are row or column matrices. Thus if we de-

    18

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    18/31

    ne R =

    a b c d

    and C =

    2664

    0123

    3775, then sin R =

    sin a sin b sin c sin d

    and sin C =

    2664

    0sin1sin2sin3

    3775 when

    we apply Evaluate or ctrl/cmd + e. It works the same

    way for user dened functions and their derivatives, andfor raising to powers. Thus 2R =

    2a 2b 2c 2d

    and

    R2 =

    a2 b2 c2 d2

    . When both the base and ex-ponent are rows or columns, the result is always a matrixwhose rows correspond to the base and whose columns cor-respond to the exponent, whether or not those arrays arerows or columns. Explore this by working the followingexamples. First dene R and C as above, and also de-ne S =

    0 1 2 3

    and f(x) = x sin x. Remove the

    denitions after you have nished the examples.

    1. f(C)

    2. f(S)3. f0(S)

    4. f00(S)

    5. 3C

    6. 3S

    7. log R

    8. RC

    9. RS

    Matrix Valued Functions

    We can dene functions, such as this one, whose values arematrices.

    (x) =

    x sin x

    ex x3

    At the moment all we can do with them is evaluate

    and dierentiate. For example, () =

    0

    e 3

    and

    (i) =

    i i sinh 1 i3

    . Evaluate 0(x) and 0(), and

    other forms for dierentiation.

    Piecewise-Dened Functions

    Another class of matrix-valued functions are the piecewise-dened functions which are dened by dierent expressionson dierent parts of their domain. Here are two examples.

    Note that we have made some very strict conditions

    concerning the structure of case functions. They must bespecied in a 3 column matrix with at least two rows, withthe functional values in the rst column, \if" or \ if" inthe second, and the range condition in the third column.

    The range conditions should be entered in the order ofincreasing values. We have also assumed that the matrixis fenced with a left brace and the empty right delimiter.The two following examples should clarify matters.

    Dene + New Denition

    f(x) =

    8>>>>>>:

    1 if x < 0undened if x = 0

    0 if x < 1undened if x = 1 2x2 if 1 < x

    Plot 2D + Rectangular f(x)Dene + New Denition

    h(x) = x + 2 if x < 1

    3=x if 1 xand evaluate the following.

    1.R20

    h(t)dt

    2.R10

    (x + 2) dx

    3.R21

    3xdx

    4.R10

    (x + 2) dx +R21

    3x

    dx

    Access to Other Maple Functions

    You can access Maple functions that are not supporteddirectly in cientic WorkPlace. Here is how you do it.Choose Dene Maple Name under the Dene submenu. Fillout the dialog box that comes up. If nextprime is theMaple functions you want, type in nextprime(x). In theScientic WorkPlace line, use a single character unless youhave a custom name prepared: In any case follow it by theargument \(x) ". Leave the le name blank. Then checkthe appropriate Maple package. Then choose OK. That'sit.

    The items Undene, Show, Save, and Restore under theDene submenu work for these Maple function as for thosedened in Scientic WorkPlace. Clear Denitions does not

    remove these. They must be removed one at a time usingUndene. The format in Show Denitions for the Maplefunctions is a bit dierent, so you can tell which are ac-cessed from Maple and which are Scientic WorkPlace -dened.

    User Dened Maple Functions

    You can access user-dened functions written in Maple.While in a Maple session, save the function to a le

    19

  • 7/28/2019 Scientific WorkPlace Demonstration Document

    19/31

    lename.m. To access `yourfunction(x)' do the follow-ing. While in Scientic WorkPlace , choose Dene MapleName. Fill out the dialog box with `yourfunction(x)' in therst line, and so on. The File line must give the completepath. It should read `/dirname/subdirname/lename.m'Note the forward slashes. Also you should check all appro-priate Maple packages. The items in the Dene submenuwork the same way for these functions as for the Maple-dened functions.

    2D Plots

    The plotting capabilities of Scientic WorkPlace are amongits most powerful and useful features. For example, beingable to plot functions and expressions quickly, revise the plots,and examine the results adds an experimental dimension toproblem solving that was not easily accessible in the past.

    We begin by discussing the various items under the Plot2D menu. To plot an expression involving one variable, suchas x sin x, put the insertion point in x sin x and from the Plot2D submenu, choose ectangular. A frame containing a plotof the expression appears in-line after the expression, with

    the lower edge resting on the text baseline and the insertionpoint at the right of the plot The rst attempt at a plotuses default parameters, with x ranging from 5 to 5, andthe range of y depending on the expression. In the Settingsmenu you can change the default size of the plot box. Makethat plot now of x sin x.

    A single click of the mouse with the pointer inside theframe causes 8 black handles to appear. We say that theframe has been selected. In this state, you resize the frameby grabbing one of the handles and dragging. The cornerhandles leave the opposite vertex xed while moving the twosides adjacent to the handle. The edge handles move only thecorresponding edge in or out. Either type of change stretchesor shrinks a plot in the view, along with the frame. Resizingthe frame retains the same limits on the view. If the frame hasbeen selected, you can move it up and down by placing themouse pointer inside it, holding down the left mouse buttonand dragging. Experiment with these things on the plot ofx sin x you have just made.

    There are various ways in which you can instruct Scien-tic WorkPlace to plot. If you want to plot y = x sin x, youcan do any one of the following things.

    1. Click in x sin x or highlight it and choose Plot 2D +Rectangular.

    2. Dene y to be the expression x sin x, put the cursor justto the right of y; or highlight y and choose Plot 2D +Rectantular.

    3. Dene the function f(x) = x sin x, put the cursor inf(x), or highlight f(x), or highlight the function f, andchoose Plot 2D + Rectangular.

    Now plot the function y = x sin 1x . Double click themouse with the pointer inside the frame. Eight gray handlesappear on the frame, and the mouse pointer takes the shape

    of a hand when it is over the view. We say that the view hasbeen selected.

    To translate a view, select the view by double-clicking,move the mouse pointer over the view, so that it takes on theshape of a hand, and click and drag the frame. An outline ofthe frame moves as you drag, while the plot remains xed.When you release the mouse button, the frame is redrawn atits original position with a translated view. This feature isused to \pan" across the Cartesian plane in any direction to

    capture dierent portions of the plot. Experiment with thisusing the plot of x sin 1

    xthat was made above.

    Frame Properties Dialog Box

    You use the Frame Properties dialog box to specify framedimensions precisely and to determine how the frame is placedin your document. This time we will work with the plot ofthe piecewise dened function

    h(x) =

    8