Top Banner
CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 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.
24

CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Jan 03, 2016

Download

Documents

Diane Sanders
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

CS 121 Engineering Computation Lab Lab 4

Department of Computer ScienceDrexel University

Summer 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.

Page 2: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Your class instructor and TA

• Instructor for this section: Office: Email: Telephone:

• Your TAs are: Note that verification sheet requires you to put

down instructor’s name.

Page 3: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Upcoming Activities

• This Week (Week 4)• Quiz 4 (Tuesday – Friday)

• Next Week (Week 5)• Lab 5 on Monday (7/20)• Proficiency Exam on Wednesday (7/22)• Instructions for Proficiency Exam

• Sent later this week.• Via e-mail and Wednesday recitation

Page 4: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Lab 4

• Part 1 Multiplotting – Problem 1.1

• Part 2 Import Data – Problem 2.1

• Part 3 Piece wise functions – Problem 2.2

• Part 4 Maps – Problem 2.3

Page 5: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Multiplotting

• Basically means plotting more than one graph in a plotConsider 2 functions – x^2,x^3

• Chapter 6 – Section 6.3• Syntax – plot(set of expr,var=range, color=list of colors)• How do we plot it for the above 2 functions

plot({x^2,x^3},x=0..10}

The functions in plot can also be user defined functions. Part 1.1 of the lab requires this.

Page 6: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Multiplotting (cont)

• Coloring Multi plotsAutomatically colors are chosen.

• How to plot with specified Color ?We do this by changing the parameter of Plot

Plot({f(n),g(n)},x=0..100,color=[“red”, “green”, “blue”])

Page 7: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Demo of Multiplotting

Plot for x^2 and x^3, using plot({x^2,x^3},x=0..10)

Page 8: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Demo of Import Data (Text) Instructors can use the following slides optionally.

grades := ImportMatrix(‘GradeData1.csv’,source=csv)

gradeList := convert(grades,list)

OR

ImportData()

Page 9: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Demo of Import Data (Click) Instructors can use the following slides optionally.

Page 10: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Demo of Import Data (cont’d)

Page 11: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Demo of Import Data (cont’d)

Page 12: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Demo of Import Data (cont’d)•Right Click on the Blue Matrix. Click Assign to a name.•The name used here is ‘thelist’•Convert the matrix to a list using

•Mainlist := convert(thelist,list)Perform the required operations on the Mainlist

Page 13: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Part 3 : Piecewise Function

What is Piecewise Function?– It is a function whose definition is dependent on the

value of the independent variable.

Page 14: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Part 3 : Piecewise Function

• Piecewise functions are defined using the common functional notation, where the body of the function is an array of functions and associated sub domains.

Page 15: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Part 3 : Piecewise Function• Maple Notation for a piecewise function

• Use the curly braces from Expressions

• Use Ctrl + Shift + R to add new row to the function

Page 16: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Part 3 : Piecewise Function

Demo of Piecewise Function– Show demo for absolute value

Page 17: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Part 4 : Maps

• A function that associates a single output to each input element drawn from a fixed set such as the real numbers

• In our case the fixed set is a List – Problem 2.2 and Problem 2.3

• Use map for element-wise application of a function

Page 18: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Syntax

map(function or function name, structure)

Part 4 : Maps

Page 19: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Example

i) L:=[52,53,54]

f:=(b,x)->sin(x*Pi/b)

map(f,L,2)

ii) map(binomial,L,6)

Part 4 : Maps

Page 20: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Part 4 : Maps + Piecewise Function• Demo

- Piecewise function for Pass or Fail

Page 21: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Part 4 : Maps + Piecewise Function• Demo

- Map it with a list of marks

Page 22: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Finishing up – save your work

• Save worksheets onto the Desktop. You can call them Lab4Part1, Lab3Part4, etc. Or you could put all the work into one worksheet and just call it Lab 4.

• Submit a copy to Blackboard site as evidence that you did the lab.

• Email a copy to yourself and/or your lab partners as an attachment so you can look at what you did for review purposes later.

Page 23: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Turn in your verification sheet

• Make sure your name/user id/section number/ date,time/instructor name are on the verification sheet.

• Get the verification sheet signed for all parts you completed and hand it in.

Page 24: CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.

Weeks 7 and 8

• Take Quiz 4 Monday-Friday Week 8– Novomber 10-14– Maple TA server down for maintenance 9-

10am and briefly at 3pm each day during the week.

– All the best