Computer Lab #1: Introduction to Wolfram Alpha Introduction: Many of the techniques in calculus are based on firm rules. It is therefore possible to program a computer to perform such operations, and indeed the last decades have seen the arrival of many computer algebra systems, for example Maple, Matlab, Mathematica, MuPAD, Reduce or Derive (to just name a few prominent ones). These systems provide complete programming environments. In this course we will use a web-based system, called Wolfram Alpha (we will use the abbreviation W∣α from now on) which is based on the engine underlying Mathematica. The choice was chosen primarily as it is easily accessible and free to use. However it is more limited than the full-featured systems available commercially. The use of this computational tool will allow us to study phenomena without being hampered by the need to perform difficult calculations by hand, and this is what we will do in these labs. Each of the labs will introduce a few techniques and then ask you to use these techniques in your own investigation of given problems. You should follow through the lab description and issue the commands given to see the system behavior. The labs also serve as a practice on writing reports, something you will have to do in your job as mathematician, scientist or engineer. We will give you more information about this towards the end of this lab. Given the capabilities of such a system, you also might wonder why we (still) teach these techniques? (Though you also still learn writing though there are computers and printers.) The reasons are that even the best programs still have bugs (and understanding of the concepts is necessary to realize that a bug happened), and they still are not as powerful as a human. The mastery of integration techniques also serves as a good training towards using higher level techniques that you will encounter in your subject courses in higher semesters. We’ve also talked to faculty in many disciplines outside mathematics and again and again got the response that they felt integration techniques were a valuable tool to know and should be taught in a calculus course. We also understand that tools like W∣α will be able to solve many of the homework problems you are given, but that is no reason why you should not do the homework by hand. (After all a solution manual, found on some dodgy website, will serve the same purpose.) Cheating on the homework will only harm you in the exams. However we encourage you to use the computer to check your results (or even in some cases as guidance to problems you don’t know how to do) – just resist the temptation to copy the computer’s work as your own. Commands Reviewed: arithmetic,?,plot,limit,diff,integrate The system interface sum x, x=1..(number of american presidents)^2 = You start W∣α by pointing your web browser to www. wolframalpha.com. If you have a smartphone or tablet, We will not investigate this feature but stick to rather forthere also are dedicated apps available that provide a slicker malized input.) interface. The system then returns the output in a sequence of The system gives a box into which you type your quesboxes, separated in different categories. (For example for a tion or command: function it might give a plot, the derivative and other properties.) Typically these boxes have a widget in the lower left = corner that lets you save the result as a graphics file (needed and you hit the return button or click the equal sign. for the lab reports!). The upper right corner might contain W∣α then evaluates the expression and tries to perform the interactive boxes, such as more digits, or show steps. task given. Some of the boxes might involve advanced material that Sometimes the meaning of the question is not clear and we will cover only later (or only in higher level courses). W∣α will tell you so, or tell you what it understood. (The manufacturer also proudly claims the availability of a large Basic Algebra data base and of language parsing, such as how much does a car weigh in ounces For a start, lets look at some basic algebra: = or 1/7+1/5 1 = Graphing Symbolic Expressions Note that you also can use variables, and the system will work symbolically: W∣α has a variety of plotting capabilities and commands. command. Lets consider the plot of arcsin. The first Note that you can consider this as an algebraic expres- method is to try sion, as an equation 1/7 + 1/a = 0, or as a function of a, plot arcsin(x), x=-1..0 = and W∣α will give you answers to many of these interpretations. This of course means that you need to understand what answer you should expect to a problem (which is not In this form, we have chosen the x-axis to go from -1 to just given as system input). 0 and the y-axis chosen to make the graph fit. If you also wanted to specify a particular y-axis you could use Using variables we can form and solve polynomials 1/7+1/a = x^2+3*x+1=0 = plot arcsin(x), x=-1..0, y=-2..2 or even (this is something hard!) polynomial systems or for example to plot over the x-interval [−1, 1] use = x*y+1=0, x^2+x*y=2 = Similarly one can calculate intersection points of functions plot arcsin(x), x=-1..1, y=-2..2 = = exp(x)=cos(x) Sometimes you want to use a plot to compare several functions. You can do so by enclosing the functions in squiggly brackets W∣α also knows about constants, such as = Pi and for many numerical results that cannot be expressed plot arcsin(x),cos(1/x), x=-1..1, exactly offers the ability to obtain more digits. Note that y=-2..2 = a command cos(Pi/2) gives an exact result, while something like cos(3.1415926/2) just returns an approximation. Let’s examine one more example of W∣α ability to ma- Calculus Operations nipulate symbolic expressions. Recall from class that we The most important operations in calculus can be perhave the cancellation equations for sin and arcsin formed symbolically in W∣α. Among these we review x = arcsin(sin(x)) for x ∈ [−π, π] computing limits, derivatives, and integrals. x = sin(arcsin(x)) for x ∈ [−1, 1] sin(x) To compute the limit of as x approaches 0, type x We want to verify if these identities really work in W∣α. Using the well known fact that limit sin(x)/x, x=0 √ 2 sin(π/4) = 2 we will evaluate the right hand side of the identities given above sin(arcsin(1/2*2^(1/2))) = arcsin(sin(Pi/4)) = = Note that if we ask instead limit sin(x)/x^2, x=0 = W∣α automatically indicates that right and left sided limits differ. Differentiation works similar: We see that again W∣α performs the operations using differentiate sin(x)/x basic operations and identities, instead of doing the computation numerically. W∣α knows about domains of func- or tions as you can see with d/dx sin(x)/x arcsin(sin(5/6*Pi)) = which generalizes easily to higher order derivatives 2 = = d^3/dx^3 sin(x)/x a person who has taken Calculus 2. Imagine that you are working for a company and your supervisor gave you these problems as a task to return the answers in written form, or imagine the lab report was to be handed out in class. The appropriate look means that (unless you have a particularly neat handwriting and can write immediately in a final form – I yet have to meet such a person) the report should be typed up in a word processor and then be submitted on paper. Many people use the program “Word” by Microsoft, but you are welcome to use whatever word processor you like – for example “Abiword” and “OpenOffice” are free alternatives. If you use “Word”, one tool that might help you is the Symbol window. By clicking Insert and then Symbol, you get a window that will allow you to insert an assortment of symbols in your document. You can also insert an assortment of mathematical expressions by clicking Insert, then Object, and then selecting the Equation Editor. Unless you have a specialized equation package, this is the only way that you can easily include mathematics in your document. You should indicate explicitly the command you gave to W∣α and the relevant part of its answer. In some cases a plot or graphics is part of the answer and should be included. This inclusion should be at the place to which the graphic is referred, and not just in an obscure appendix. If the graphics file requires further labeling this should be added. Also parts irrelevant to the report should be trimmed off. (Being able to do some basic editing of graphics files is a very useful skill for your work beyond this course as well, which is the reason for asking you to do so.) When it is time to insert your plot in your Word document, you click on Insert/Picture/From File. Word will give you a browsing window that will let you find your file. You click on the file that you want inserted and it appears in your Word document where your cursor was situated. And finally, you should understand that by clicking on the plot in your Word document, Word will allow you to move the plot around and to resize it. = Similarly, we can integrate both indefinite integrate 1/(1+4*x^2) = or definite integrate 1/(1+4*x^2), x=0..1/2 = Note that the indefinite integral offers a box show steps that lets you see the integration process. You should be aware that this is not always the easiest or shortest way to solve a particular integral, but in general it works pretty well. You also should notice W∣α often provides links explaining what a particular function (such as tan−1 in the example) is. It should be made clear that we have just touched on some of the capabilities of W∣α. The system can perform the full range of algebraic manipulations, such as solving equations, simplifying equations, expanding equations, etc. Differential Equations We’ve looked at some basic examples of differential equations. For example, we have seen equations of the form = y’(x)=5*y(x) and initial value problems such as y’(x)=5*y(x), y(0)=1 = Now assume there growth factor depends on the value of y(x) (say, there is limited space or resources) so we get an equation such as y′ (x) = (5 − 2y) ⋅ y (This is called the logistic equation.) Look at the solutions for a few initial values and note how the solutions always converge to the same value 2.5 in this example. We You may hand in the reports in groups of at most three, wouldn’t yet know how to solve this equation, though you all three people must be in the same section. (By handing will in a course on differential equations. in the report you assert that all members of the group contributed about equally and all understand the whole subThe Report mission.) The usual rules about copying and academic As insinuated in the preamble, your homework assign- honesty apply. ment for this lab is to write a lab report. This report should You are explicitly forbidden to hand in a report based look appropriate for the work of a college student who can on work that was not done by you or not done this read and write in English. That means, the report should semester. (This means in particular that reports that were not only lists terse answers (or formula clips), but con- handed in before by other people, or handed in in a previsists of running text that can be read and understood by ous semester are not acceptable.) 3 If you save files on the computer, make sure all filenames are unique – for example calling a file hw1YourName and not just hw1 – as all users are using the same class account. Also copy all files you create on a memory stick or floppy that you brought with you, as any files on the departmental machines could get erased. 3. When plotting two functions, W∣α also shows a “parametric plot”. Describe what this is. (You might want to try out some functions to see what happens.) Produce a parametric plot that is a perfect circle with radius 2. 4. Compute the limit Good luck! sin(h + x) − sin(x) h→0 h lim The Problems and interpret the result. Give your answers in the form of a clearly written report. You should begin with some sort of Introduction which is not just copied from this handout and end with a summary that is more than “I learned how to use W∣α”. Answer the questions with complete sentences. Include the W∣α graphs into your text (not at the end in some obscure appendix) by exporting the picture as a .gif file and then pasting it into your word processor. You will be graded on the presentation as well as correctness. If you run into problems attend an office hour and get help. Don’t just claim in your report that it did not work out! 5. Compute the following derivatives x2 − 3 x3 + 2 a) dg (0) dx for g(x) = b) d2 g (0) dx 2 for g(x) = e x cos(x 2 + 1) 2 6. Compute the following integrals: ∫ 0 1. Study the expressions 3 x 4 e 3x dx, and ∫ 1 x 2 sin(4x)dx −1 2 7. Consider the function f (x) = e x −12x x 14 . What is the (approximate) y-range of this function if 0 ≤ x ≤ 1? sin(arcsin(x)); arcsin(sin(x)); Does W∣α give correct results? Does W∣α give the results that you would have guessed it should give — given that you have studied these equations in the book? Why do you think W∣α gives the answers that they give? Now calculate ∫ 1 0 f (x)dx. What happens? (W∣α is updating its output, note the intermediate parts.) You will get a negative value. Can you explain why? (Hint: Use the More digits button.) What does this mean for results obtained by the computer? 2. Let a be the current year minus 2010, i.e. in 2012 we have a = 2. Let b be the number of the month (i.e. September=9). Plot the functions f 1 = sin(x) and f 2 = −a⋅x 2 +b⋅x +1 on an interval that shows the two intersection points clearly and with y-range [−2, 2]. Label the intersection points with the approximate (3 digits) (x, y)-values for their coordinates. 8. Determine a solution to the initial value problem y′ (x) = 3x 2 + 4x + 2 , 2(y − 1) y(0) = 5 Verify (using W∣α for differentiation if you want) that indeed the solution fulfills the equation. 4