Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 121 Engineering Computation Lab Lab 2

Similar presentations


Presentation on theme: "CS 121 Engineering Computation Lab Lab 2"— Presentation transcript:

1 CS 121 Engineering Computation Lab Lab 2
Bruce Char Department of Computer Science Drexel University January 26-30, 2009 ©By the author. All rights reserved. Permission is given to CS121 Fall 2008 staff and students to use and reproduce these notes for their own use.

2 Your class instructor and TA
Instructor for this section: Timothy Cheeseman Your TAs are: 061 – Cem Sahin, Lloyd Ricks 561 – Patrick Lockner Note that verification sheet requires you to put down instructor’s name.

3 Week 1 and 2 retrospective
Lab 1: First week Quiz 1: Second week If you are a latecomer and are catching up? Talk to instructor!

4 Lab 2 Overview Part 1 Limited precision numbers (Ch. 3 readings)
Part 2 Data structures, functions (Ch. 4 readings)

5 Limited precision arithmetic
Limited precision arithmetic: use 10 digits (or some other fixed number such as 20). Perform an operation using as many decimal digits as necessary. Round the result to 10 decimal digits. Do the next limited precision arithmetic operation. Repeat until all the operations are done.

6 Adding 111.11 and 7.7777 in 5 digit limited precision arithmetic
: ________ exact answer rounded to five digits (final result)

7 Five digit limited precision in Maple

8 Ten digit limited precision arithmetic is Maple’s default (no evalf necessary)

9 Exact arithmetic is not the same as limited precision arithmetic
Exact arithmetic always works things out to exactly. Operations between integers stay as exact integers. Operations with fractions stay as exact fractions.

10 Two kinds of arithmetic
Maple does exact arithmetic with exact numbers Maple does limited precision arithmetic with limited precision numbers. How does Maple know what to do with a number? By the way it looks. Numbers with decimal points, :”e’ exponents are limited precision numbers Numbers that are integers or ratios of integers without decimal points are exact numbers. Symbolic constants are also considered exact numbers.

11 Floating Point Numbers
Having a decimal point written with them Considered as limited-precision numbers in Maple Answers are rounded to the number of digits of accuracy e.g. 1111.1, meaning the limited-precision version with 5 digit numbers

12 “e” notation Scientific notation using “e” to indicate the exponent
Considered as limited-precision numbers in Maple Do not use “e” for logarithms from the palette, but type the letter e on the keyboard normally e.g.: 7e11, meaning 7*1011 2e-8, meaning 2*10-8

13 How do you convert an exact number into an approximate number?
Clickable Approximate->20 evalf( expr) or evalf(expr,digits)

14 Bonus (not mentioned in chapter readings): how do you convert an approximate number into an exact number?

15 Maple as a math word processor (sect 4.1, 4.4.5, 4.4.6)
Ordinary entry is 2D Math mode Can enter text. Once in text mode, can do boldface, italics, center-justification as with a word processor. Control-T/Control-R (Command-T/Command-R) to switch between the two. When in doubt click cursor on position, then do Format -> Create Document Block. Switch to proper mode and start typing.

16 Demo of Math text entry Demo of word processing.
Demo of Greek letters (section 4.4.6), math constants, subscripts in math mode.

17 Assignment, labels (sect 4.2)
Hitting enter (return) gives a result a numerical label. Control-L (command-L) to refer to a result by its label. name := expression Is similar – turns that into a label for the result of evaluating the expression. Both are useful when you want to refer to results in later steps of a calculation.

18 Demo of assignments and labels
Replace with demo of assignment and labeling at work.

19 Functions (Sect 4.4) Function name ( input ) produces an output.
Most math functions take one numerical input and produce one numerical output. Some math functions take two numerical inputs and produce one numerical output. Maple functions do this and more: sometimes the inputs and outputs are not numbers.

20 Function demo Demo textual entry of:
Sqrt, exp, abs, sin, cos, min, max

21 Maple has “non math” functions (sect 4.4.7)
function name( input1, input2, … ) with output. Inputs and outputs do not have to be numbers.

22 Demo of non-Math functions
Demo of solve, factor,eval, plot

23

24 Finishing up – save files
Make sure your name/user id/section number/ date,time/instructor name are on the verification sheet. Get the verification sheet signed and handed in. Save worksheet on desktop if you haven’t done so already. You can call the file “MyLab1”. This will create a file called MyLab1.mw. Opens on any machine running Maple 12. Submit a copy to Blackboard site as evidence that you did the lab. This is not required but can help you later. a copy to yourself and/or your lab partners as an attachment so you can look at what you did for review purposes later.

25 Week and 4 Did you enter in week 2 or 3?
Talk to the instructor during their office hours about catching up with missed material. Take Quiz 2 Monday-Friday Week 4 Look for Chapter 5,6 released at end of Week 4


Download ppt "CS 121 Engineering Computation Lab Lab 2"

Similar presentations


Ads by Google