Introduction To Computing Using Matlab

Transcription

Introduction to ComputingUsing MatlabCS 1112Dr. K.-Y. Daisy sion starts next week!In Upson 225 lab, not classroom listed in Student Center

Today’s lecture An illuminating problemCS1112 philosophies & syllabusWhat is computer programming?Choosing between CS1112 & CS1110Course logistics/policies (highlights)Discussion starts next week!In Upson 225 lab, not classroom listed in Student CenterLecture 12

An illuminating problem: computing square roots Suppose A 0Observation: If A is the area of a square then I can just measure the side length—that isASolution idea: Make a square with area AReal task: Make a sequence of increasingly squarerectangles, each with area ALecture 15

How to make a rectangle “more square”? If a square and a rectangle both have area A then A is between the length and width of therectangleLecture 16

An improvement strategyA/LCurrent:LRecipe:Lnew (L A/L) / 2The average ofthe length andwidth.A/LnewNext:Lnew

A Matlab program to make “increasingly square” rectangles% The first rectangle.L1 A;W1 1;% The second rectangle.L2 (L1 W1)/2;W2 A/L2;% The third rectangle.L3 (L2 W2)/2;W3 A/L3;% and so on.Lecture 18

Some conclusions from square root finding problem It paid to have a geometric senseA complicated computation was reduced to asequence of elementary calculationsA program is like a formula (or sequence offormulas)Lecture 19

Course Goals Develop your “computational senses,” senses thatyou need in computer problem-solvingDevelop a facility with the Matlab programmingenvironmentLecture 110

A sense of geometryLecture 111

A sense of complexityWhat is the bestitinerary to visitBoston, Miami, LA,Dallas?3! 6 possibilitiesAdd Seattle, NYCAustin, Denver7! 5040If a computer can process 1 billion itineraries a second,how long does it take to solve a 100-city problem?Lecture 112

A sense of complexityWhat is the bestitinerary to visitBoston, Miami, LA,Dallas?3! 6 possibilitiesAdd Seattle, NYCAustin, Denver7! 5040If a computer can process 1 billion itineraries a second,how long does it take to solve a 100-city problem?About a century

A sense of approximation & error1/3 .33333 Lecture 114

A sense of randomness and probabilityRandom walkBrownian motion in waterLecture 115

Course Goals Develop your “computational senses,” senses thatyou need in computer problem-solvingDevelop a facility with the Matlab programmingenvironmentLecture 116

Computer problem-solvingKey: Algorithmic thinkingAlgorithm:A step-by-step procedure that takes you from aprescribed set of inputs to a prescribed set ofoutputsProgram:The algorithm expressed in a specific language, e.g.,MatlabLecture 117

Computer problem-solving — Programming Developing instructions for the computer toexecute (in order to solve some problem)The steps must be logicalUse a particular language and follow the rules of thelanguage (grammar/syntax)Lecture 118

Example: Adding songs from the internet to your music library Find a website with MP3 or other audio filesRegister with the music site, if required for musicdownloading. (Don’t steal music.)Click on the music file to download it onto yourcomputerDrag the file to your libraryReference: iTunesLecture 119

Example: Adding songs from the internet to your music library Drag the file to your libraryClick on a music file to download it onto yourcomputerFind a website with MP3 or other audio filesRegister with the music site, if required for musicdownloading. (Don’t steal music.)Lecture 120

Example: Adding songs from the internet to your music library Find a website with MP3 or other audio filesRegister with the music site, if required for musicdownloading. (Don’t steal music.)Click on the music file to download it onto yourcomputerDrag the file to your libraryReference: iTunesLecture 121

Example: Adding songs from the internet to your music library Find a website with MP3 or other audio filesRegister with the music site, if required for musicdownloading. (Don’t steal music.)Click on the music file to dowNload it onto yourcomputerfile Drag your librAry toLecture 122

Computer programming is a tool used by computer scientists, engineers, andother professionalsnot all of computer scienceThink about astronomy: Telescope is a tool usedby astronomers; astronomy is not abouttelescopes Lecture 123

Matlab is the vehicle we useWith the Matlab environment, you can easily Develop programs Display results & ideas graphically Interact with large data sets (process text,image, and other files)Matlab has extensive libraries of mathematical,statistical, simulation, and other tools. It is heavilyused in engineering & sciences, both in industry andacademia.Lecture 126

Engineering students take one of these courses:CS1112 – this course, Matlab CS1110 – PythonEach course satisfies the Engineering ComputingRequirement. In 1112 you will learn proceduralprogramming in depth and be introduced to objectoriented programming.Each course can serve as the prerequisite forCS/ENGRD 2110 Object-Oriented Programming &Data Structure Lecture 127

CS1112 has a focus on computational science & engineeringApproximation, randomness,model building, sensitivity of models Lecture examples and homework illustrate abovethemesEdge detection Ranking web pages Congressional apportionment Lecture 130

Some past programming assignments Draw the random MondrianFind the US population centerfrom census dataOrganize protein data usingstructure arraysMozart’s musical dice gameDraw the “Betsy Ross Flag”Pyramid of Khufu, Egypt Scale is 5.54 feet per unit length on axesSelect a path using multiple mouse clicks. Click outside the map to stop.Total distance: 8379.3 feet100200300400500Path distance tool(like that in Google Earth)600700Root finding tool800900Lecture 1100200300400500600700800900100031

CS1110 – in Python Switched from Java to Python because Python is afriendlier and more modern object-orientedlanguage.Python is more relevant to non-computerscientists than Java—numerical libraries areavailableMatlab and Python are just different vehicles we Conducive to discussion of designuse to travel the “computational landscape.” Different scenery along the way Both vehicles can get you thereLecture 132

CS1112 No priorprogrammingexperienceOne semester ofCalculusFocus oncomputationalscience &engineeringMatlabCS1110 Lecture 1No priorprogrammingexperienceNo CalculusFocus on softwaredevelopmentPython34

Related to CS 1112: ENGRG 1112 Taught by Prof. Andy Ruina of MAE, “PracticalComputing for Engineering”1 credit, optional, Fri 2:30-3:20pm, Kimball B11Course oriented towards numerical methods inengineering and includes symbolic computation,all in MATLAB“Intersection” of computing, engineering math,and engineering A18/class/ENGRG/1112Lecture 135

CS1112 requirements4 credits 4x3 12hrs/weekIn class: 2hr lec 1 hr dis 3 hrs/weekOutside class: 9 hrs/week Attend lectureAttend discussion—get individual attention/help onweekly exercises!Monitor course announcements on websiteDo homework: best 5 of 6 programming projectsTake 2 prelims and a final exam at their scheduled timesAnswer in-class quizzes (use your clicker)Adhere to the Code of Academic IntegrityLecture 141

Grading Best five* of six projects (25%) Your lowest-scored project is eligible to be dropped only ifyou scored at least 50% on itDiscussion exercises (4%)In-class quizzes (1%)Prelim 1 (20%)Prelim 2 (20%)Final exam (30%)Lecture 142

Course Materials Insight Through ComputingA Matlab introduction to Computational Scienceand Engineering An iClicker clicker(or mobile app)MATLAB Student Version (2008 orlater) download your own copy or usepublic computer labs (Engineering Quadand RPCC)Lecture 143

Consulting & Computing Consulting in ACCEL Green Room (EngineeringLibrary, Carpenter Hall). Check course websitefor hours. To download MATLAB, see course website Some labs that have MATLAB: Upson 225ACCEL Carpenter Hall study areaNorth campus: RPCCLecture 146

CS1112 Discussion Sections – start next weekSec #TimeRoom201T 12:20-1:10pUPS 225 lab & HLS 401202T 1:25-2:15pUPS 225 lab & HLS 401203T 2:30-3:20pUPS 225 lab & HLS 401204T 3:35-4:25pUPS 225 lab & HLS 401205W 10:10-11:00aUPS 225 lab & HLS 401206W 11:15a-12:05pUPS 225 lab & HLS 401207W 12:20-1:10pUPS 225 lab & HLS 401208W 1:25:2:15pUPS 225 lab & HLS 401209W 2:30-3:20pUPS 225 lab & HLS 401210W 3:35-4:25pUPS 225 lab & HLS 401Discussions are held in UPS B7(Upson)the first225twolab weeksthe first two weeksLecture 150

CS1112 – this course, Matlab CS1110 –Python Each course satisfies the Engineering Computing Requirement. In 1112 you will learn procedural programming in depth and be introduced to object-oriented programming. Each course can serve as the prerequisite for CS/ENGRD 2110 Object-O