Iteration. The final line is simply ending the do word in the first line. You can put as many lines as you like in between the do and the end do

Size: px
Start display at page:

Download "Iteration. The final line is simply ending the do word in the first line. You can put as many lines as you like in between the do and the end do"

Transcription

1 Intruction Iteration Iteration: the for loop Computers are superb at repeating a set of instructions over and over again - very quickly and with complete reliability. Here is a short maple program ce that follows shows how to do that with a very simple example. restart : for i from 1 to 8 by 2 do print "here's ", i, "squared - in various forms: ", i $i, i $ i $ 1.0, evalf i $i, i 2, i 2.0 ; end do "here's ", 1, "squared - in various forms: ", 1, 1.0, 1., 1, 1. "here's ", 3, "squared - in various forms: ", 9, 9.0, 9., 9, 9. "here's ", 5, "squared - in various forms: ", 25, 25.0, 25., 25, 25. "here's ", 7, "squared - in various forms: ", 49, 49.0, 49., 49, 49. (2.1) The first line of the ce is saying:run the next lines again and again for i going up from 1 to 8 in steps of 2 The second line is printing i squared using various meths. See if you can figure out why the answers are the way they are; some with decimal points - some without. If you don't know what evalf means then type?evalf and press the return key - and you'll get some help; it means evaluate using floating point arithmetic [ not exact arithmetic ]. The quotation marks in the output are a bit ugly; they can be got rid of but that's not important here. The final line is simply ending the do word in the first line. You can put as many lines as you like in between the do and the end do You should now try your own for loop by mifying this one. Note that at the end of the first and second lines in the ce above you should press shift return rather than just return. Return forces a calculation, shift return gives you a new line. Note there is no semi-colon at the end of the for line. Iteration : the while loop i d 1 : while i 2 % 64 do print "here's ", i, "squared - in various ways: ", i $i, i $ i $ 1.0, evalf i $ i, i 2, i 2.0 ; i d i C 2 : end do: "here's ", 1, "squared - in various ways: ", 1, 1.0, 1., 1, 1. 1

2 "here's ", 3, "squared - in various ways: ", 9, 9.0, 9., 9, 9. "here's ", 5, "squared - in various ways: ", 25, 25.0, 25., 25, 25. "here's ", 7, "squared - in various ways: ", 49, 49.0, 49., 49, 49. (3.1) This while loop does the same thing as the for loop above. It seems a little bit clumsier, but it is very powerful - especially when you don't know in advance just how many times you need to run through a loop: Note in this example the while condition is that i 2 % 64 - not the simpler previous i % 8. The while loop above can be read as follows: Take my counting variable i and set it equal to 1. Start a loop that will run until 64! i 2. Print out i squared. Increment my counting variable by 2. End the loop. Note the use of the colon and the semicolon. Using the colon at the end of the do loop I tried to suppress computer output - otherwise I'd keep getting the i:= i + 2 line giving me the latest value of i. Note also that in this latest version of Maple [ 13 ], the semi-colon is often unnecessary. Space is too short to give examples here of when it is and is not necessary but you'll pick it up very quickly. Iteration: the do loop i d 1 : do if i = 250 then print "i should be 250, check here:", i ; break: end if: i d i C 1 : end do: "i should be 250, check here:", 250 (4.1) This do loop would run forever unless the loop at some stage reaches the break command. This type of loop can be very powerful indeed, although some purists might frown on its use! predicates: the if word... here is an example of the if word in Maple a d 7 a := 7 (5.1) if a! 7 then print " a is less than seven: ", a ; 2

3 if a O 7 then print " a is greater than seven: ", a ; if a = 7 then print " a equals seven: ", a ; print " a equals seven: ", 7 (5.2) if a R 7 then print " a is O= ", a ; print " a is O= ", 7 (5.3) if a % 7 then print " a is!= ", a ; print " a is!= ", 7 (5.4) The if statement can be enhanced a bit using the else word as follows: if a! 7 then print " a is! seven: ", a else print " a is O= 7 ", a ; print " a is O= 7 ", 7 (5.5) note that we can use the "not equal to" construction in maple as follows: if not a = 8 then print " a is not equal to eight: ", a else print " a is equal to 8 ", a ; print " a is not equal to eight: ", 7 (5.6) Note the kind-of reverse logic on the first line above. Using the palettes on the left you can find slightly nicer ways to write this: if a s 8 then print " a is not equal to eight: ", a else print " a is equal to 8 ", a ; print " a is not equal to eight: ", 7 (5.7) 3

4 You can think of else as meaning the same thing as "otherwise". Let's try something slightly more ambitious using for loops and while loops and if. Using a for loop let's find the smallest positive integer n such that 1000! n C 1 3 K n 3 restart : for n from 1 to 20 do if n C 1 3 K n 3 O 1000 then print n end if end do (5.8) Remember that you use the cursor keys to, for example, get down from the power of 3 to the base line before you type the subtraction symbol. Note also the complete departure from old versions of Maple; in this example there are no semi colons or colons. Remember to get to the "next lines" in this example you press shift-enter. Note that the ce can also be written all on one line, although its hard to see any benefit from doing so apart from saving paper maybe. for n to 20 do if n C 1 ^3Kn^3 O 1000 then print n end if end do Note in the next example the cryptic but cute shorthand where "fi" is like a bookend to the intructory "if"; the suggestion being "fi" is shorthand for "end if". Similarly with "" - its the mirror-opposite of "do" so to speak, and so ends a "do" statement, replacing "end do". (5.9) for n from 1 to 20 do if n C 1 3 K n 3 O 1000 then print n fi (5.10) Note above the attempt at indentation of ce. Not important in such a short piece but for long complex ce you will come to bless the facility to indent ce. Its makes it easier to read. The "if" 4

5 section is kind-of contained within the "for" section. And the the "print" section contained within the "if" section. for n from 1 to 20 do if n C 1 3 K n 3 O 1000 then print n fi (5.11) 17 C 1 3 K C 1 3 K (5.12) (5.13) Our ce above works okay but isn't very go. First: how was I to know that the answer was about 18 or 19 and so only needed to do my loop that many times? The while loop will do something similar: n d 1 n := 1 (5.14) Note that we need to "start n off" with a value here. We call this "initialising". while n C 1 3 K n 3! 1000 do n d n C 1; end do; n := 2 n := 3 n := 4 n := 5 n := 6 n := 7 n := 8 n := 9 n := 10 n := 11 n := 12 5

6 n := 13 n := 14 n := 15 n := 16 n := 17 n := C 1 3 K (5.15) (5.16) You can use the sometimes invaluable break word in Maple to tidy up the for loop above: restart : for n from 1 to 20 do if n C 1 3 K n 3 O 1000 then print n, n C 1 3 K n 3 ; break; fi; ; 18, 1027 (5.17) note again the use of the shorthand above for end if [ fi ] and end do [ ] The while loop can be tidied by suppressing output until the end: n d 1 : while n C 1 3 K n 3! 1000 do n d n C 1; : n; 18 (5.18) Summing using a loop total d 0 : Note the variable above is initialised. for i from 1 to 10 do total d total C i total := 1 total := 3 total := 6 total := 10 total := 15 6

7 total := 21 total := 28 total := 36 total := 45 total := 55 (6.1) Make sure you can understand the above program and output. Next, examine this ce and output: total d 1 : Note it wouldn't make sense to initialise this total variable to zero for i from 1 to 10 do total d total i total := 1 total := 2 total := 6 total := 24 total := 120 total := 720 total := 5040 total := total := total := total d 1 : Note: in the ce above can also be written:- for i from 1 to 10 do total d total $i # where the "$" is the obtained from typing the asterisk symbol. total := 1 total := 2 total := 6 total := 24 total := 120 total := 720 total := 5040 total := total := (6.2) 7

8 total := (6.3) Can you see what the above program is doing? If you need a clue - see the program below now: for i from 1 to 10 do i! (6.4) You can run a loop that stops when two values get sufficiently close [ converge ] to each other. Here is an example: restart : m d 1 : i d 2 : do n d 1 / i; if abs mkn! then print "okay - stopping now, n=", n, "and m = ", m, "; m-n=", evalf nkm, "and number of iterations =", i ; break: fi: m d n : i d i C 1 : : "okay - stopping now, n=", "and number of iterations =", , "and m = ", 1, "; m-n=", K , 100 (6.5) The above loop demonstrates several things: 1. Convergence: an inverse is being calculated and compared in size to the previous inverse calculation. When the two are sufficiently close the values are printed out and the calculation ends. 2. The open do loop and the use of break. 3. The use of abs to give the absolute value. Was abs really necessary? 4. Just before the end of the loop, m is updated to have the most recent value of n, just before n is recalculated at the start of the next loop. 5. Can you see why we initialised i as 2 rather than 1? Note that i is incremented near the end of the 8

9 loop. That's needed because we're not using a for loop. If we'd written "for i from 1 to 100 do", we would not have needed to manually increment i. What is the possible disadvantage in this example of using a simple for loop? Newton-Raphson iteration: find the root of a function First we demonstrate a special Maple meth for illustrating Newton-Raphson: restart : with Student Calculus1 : NewtonsMeth x 3 K 3 x 2 C x K 17, x = 20, output = sequence, iterations = 10 20, , , , , , , , , (7.1) Note: the successive values of x are printed above. NewtonsMeth x 3 K 3 x 2 C x K 17, x = 20, output = plot, showroot = true, iterations = 10 9

10 Newton's Meth x f x Tangent lines From the initial point x = 20, at most 9 iteration(s) of Newton's meth for f x = x 3 K 3 x 2 C x K 17 The above demonstrates Maple using its inbuilt Newton-Raphson meth. You can see the successive x values and the associated tangents to the curve - very rapidly converging on the root. 10

11 11

Section 1: Numerical Calculations

Section 1: Numerical Calculations Section 1: Numerical Calculations In this section you will use Maple to do some standard numerical calculations. Maple's ability to produce exact answers in addition to numerical approximations gives you

More information

Lesson 3: Solving Equations; Floating-point Computation

Lesson 3: Solving Equations; Floating-point Computation Lesson 3: Solving Equations; Floating-point Computation restart; A hard equation Last time we were looking at this equation. eq := * sin() = Pi/2; (1.1) Maple didn't know the solutions. solve(eq,,allsolutions);

More information

1 Getting used to Python

1 Getting used to Python 1 Getting used to Python We assume you know how to program in some language, but are new to Python. We'll use Java as an informal running comparative example. Here are what we think are the most important

More information

Intro. Speed V Growth

Intro. Speed V Growth Intro Good code is two things. It's elegant, and it's fast. In other words, we got a need for speed. We want to find out what's fast, what's slow, and what we can optimize. First, we'll take a tour of

More information

The Bisection Method versus Newton s Method in Maple (Classic Version for Windows)

The Bisection Method versus Newton s Method in Maple (Classic Version for Windows) The Bisection Method versus (Classic Version for Windows) Author: Barbara Forrest Contact: baforres@uwaterloo.ca Copyrighted/NOT FOR RESALE version 1.1 Contents 1 Objectives for this Lab i 2 Approximate

More information

Troubleshooting Maple Worksheets: Common Problems

Troubleshooting Maple Worksheets: Common Problems Troubleshooting Maple Worksheets: Common Problems So you've seen plenty of worksheets that work just fine, but that doesn't always help you much when your worksheet isn't doing what you want it to. This

More information

Approximating Square Roots

Approximating Square Roots Math 560 Fall 04 Approximating Square Roots Dallas Foster University of Utah u0809485 December 04 The history of approximating square roots is one of the oldest examples of numerical approximations found.

More information

Transcriber(s): Aboelnaga, Eman Verifier(s): Yedman, Madeline Date Transcribed: Fall 2010 Page: 1 of 9

Transcriber(s): Aboelnaga, Eman Verifier(s): Yedman, Madeline Date Transcribed: Fall 2010 Page: 1 of 9 Page: 1 of 9 0:00 1 R1 The color s not going to show a little bit, but okay. Okay. So, um, a plus b quantity cubed, you said, means Stephanie a plus b times a plus b times a plus b /R1 3 R1 Okay, so you

More information

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related?

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related? Black Converting between Fractions and Decimals Unit Number Patterns and Fractions. Let n be a positive number. When we divide a decimal number, n, by 0, how are the numeral and the quotient related?.

More information

Table of Laplace Transforms

Table of Laplace Transforms Table of Laplace Transforms 1 1 2 3 4, p > -1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Heaviside Function 27 28. Dirac Delta Function 29 30. 31 32. 1 33 34. 35 36. 37 Laplace Transforms

More information

Square Roots: Introduction & Simplification

Square Roots: Introduction & Simplification Square Roots: Introduction & Simplification You already know about squaring. For instance, 2 2 = 4, 3 2 = 9, etc. The backwards of squaring is square-rooting. The symbol for square-rooting is " ", the

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

Lesson 4.02: Operations with Radicals

Lesson 4.02: Operations with Radicals Lesson 4.02: Operations with Radicals Take a Hike! Sheldon is planning on taking a hike through a state park. He has mapped out his route carefully. He plans to hike 3 miles to the scenic overlook, and

More information

Skill 1: Multiplying Polynomials

Skill 1: Multiplying Polynomials CS103 Spring 2018 Mathematical Prerequisites Although CS103 is primarily a math class, this course does not require any higher math as a prerequisite. The most advanced level of mathematics you'll need

More information

LECTURE 0: Introduction and Background

LECTURE 0: Introduction and Background 1 LECTURE 0: Introduction and Background September 10, 2012 1 Computational science The role of computational science has become increasingly significant during the last few decades. It has become the

More information

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure

More information

MST30040 Differential Equations via Computer Algebra Fall 2010 Worksheet 1

MST30040 Differential Equations via Computer Algebra Fall 2010 Worksheet 1 MST3000 Differential Equations via Computer Algebra Fall 2010 Worksheet 1 1 Some elementary calculations To use Maple for calculating or problem solving, the basic method is conversational. You type a

More information

2: Functions, Equations, and Graphs

2: Functions, Equations, and Graphs 2: Functions, Equations, and Graphs 2-1: Relations and Functions Relations A relation is a set of coordinate pairs some matching between two variables (say, x and y). One of the variables must be labeled

More information

Getting to Know Maple

Getting to Know Maple Maple Worksheets for rdinary Differential Equations Complimentary software to accompany the textbook: Differential Equations: Concepts, Methods, and Models (00-00 Edition) Leigh C. Becker Department of

More information

Lesson 16: Integration

Lesson 16: Integration Lesson 16: Integration Definite integrals When Maple can find an antiderivative of a function, it should have no trouble with definite integrals of that function, using the Fundamental Theorem of Calculus.

More information

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel Computational Mathematics/Information Technology Worksheet 2 Iteration and Excel This sheet uses Excel and the method of iteration to solve the problem f(x) = 0. It introduces user functions and self referencing

More information

MITOCW watch?v=se4p7ivcune

MITOCW watch?v=se4p7ivcune MITOCW watch?v=se4p7ivcune The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM

YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM TOPIC 1 INTRODUCING SOME MATHEMATICS SOFTWARE (Matlab, Maple and Mathematica) This topic provides

More information

Basic stuff -- assignments, arithmetic and functions

Basic stuff -- assignments, arithmetic and functions Basic stuff -- assignments, arithmetic and functions Most of the time, you will be using Maple as a kind of super-calculator. It is possible to write programs in Maple -- we will do this very occasionally,

More information

MAT 003 Brian Killough s Instructor Notes Saint Leo University

MAT 003 Brian Killough s Instructor Notes Saint Leo University MAT 003 Brian Killough s Instructor Notes Saint Leo University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

AP Computer Science Unit 3. Programs

AP Computer Science Unit 3. Programs AP Computer Science Unit 3. Programs For most of these programs I m asking that you to limit what you print to the screen. This will help me in quickly running some tests on your code once you submit them

More information

MITOCW watch?v=w_-sx4vr53m

MITOCW watch?v=w_-sx4vr53m MITOCW watch?v=w_-sx4vr53m The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To

More information

More Programming Constructs -- Introduction

More Programming Constructs -- Introduction More Programming Constructs -- Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and

More information

C++ Reference NYU Digital Electronics Lab Fall 2016

C++ Reference NYU Digital Electronics Lab Fall 2016 C++ Reference NYU Digital Electronics Lab Fall 2016 Updated on August 24, 2016 This document outlines important information about the C++ programming language as it relates to NYU s Digital Electronics

More information

What Secret the Bisection Method Hides? by Namir Clement Shammas

What Secret the Bisection Method Hides? by Namir Clement Shammas What Secret the Bisection Method Hides? 1 What Secret the Bisection Method Hides? by Namir Clement Shammas Introduction Over the past few years I have modified the simple root-seeking Bisection Method

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

Lecture #15 March 3, 2004 A Worked Problem in Floating Point

Lecture #15 March 3, 2004 A Worked Problem in Floating Point Lecture #15 March 3, 2004 A Worked Problem in Floating Point In this lecture we will use the floating point capabilities of the ARM to compute the square root of a single-precision number in register F0

More information

C1M0 Introduction to Maple Assignment Format C1M1 C1M1 Midn John Doe Section 1234 Beginning Maple Syntax any

C1M0 Introduction to Maple Assignment Format C1M1 C1M1 Midn John Doe Section 1234 Beginning Maple Syntax any CM0 Introduction to Maple Our discussion will focus on Maple 6, which was developed by Waterloo Maple Inc. in Waterloo, Ontario, Canada. Quoting from the Maple 6 Learning Guide, Maple is a Symbolic Computation

More information

Rational Number is a number that can be written as a quotient of two integers. DECIMALS are special fractions whose denominators are powers of 10.

Rational Number is a number that can be written as a quotient of two integers. DECIMALS are special fractions whose denominators are powers of 10. PA Ch 5 Rational Expressions Rational Number is a number that can be written as a quotient of two integers. DECIMALS are special fractions whose denominators are powers of 0. Since decimals are special

More information

The Justin Guide to Matlab for MATH 241 Part 1.

The Justin Guide to Matlab for MATH 241 Part 1. Table of Contents Running Matlab... 1 Okay, I'm running Matlab, now what?... 1 Precalculus... 2 Calculus 1... 5 Calculus 2... 6 Calculus 3... 7 The basic format of this guide is that you will sit down

More information

(Refer Slide Time: 02:59)

(Refer Slide Time: 02:59) Numerical Methods and Programming P. B. Sunil Kumar Department of Physics Indian Institute of Technology, Madras Lecture - 7 Error propagation and stability Last class we discussed about the representation

More information

An Introduction to Maple This lab is adapted from a lab created by Bob Milnikel.

An Introduction to Maple This lab is adapted from a lab created by Bob Milnikel. Some quick tips for getting started with Maple: An Introduction to Maple This lab is adapted from a lab created by Bob Milnikel. [Even before we start, take note of the distinction between Tet mode and

More information

Principles of Algorithm Design

Principles of Algorithm Design Principles of Algorithm Design When you are trying to design an algorithm or a data structure, it s often hard to see how to accomplish the task. The following techniques can often be useful: 1. Experiment

More information

It can be confusing when you type something like the expressions below and get an error message. a range variable definition a vector of sine values

It can be confusing when you type something like the expressions below and get an error message. a range variable definition a vector of sine values 7_april_ranges_.mcd Understanding Ranges, Sequences, and Vectors Introduction New Mathcad users are sometimes confused by the difference between range variables and vectors. This is particularly true considering

More information

6.001 Notes: Section 6.1

6.001 Notes: Section 6.1 6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of

More information

Lesson 29: Fourier Series and Recurrence Relations

Lesson 29: Fourier Series and Recurrence Relations Lesson 29: Fourier Series and Recurrence Relations restart; Convergence of Fourier series. We considered the following function on the interval f:= t -> t^2; We extended it to be periodic using the following

More information

Unit 4: Multiplication

Unit 4: Multiplication Math Fundamentals for Statistics I (Math 52) Unit 4: Multiplication By Scott Fallstrom and Brent Pickett The How and Whys Guys This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike

More information

Casting in C++ (intermediate level)

Casting in C++ (intermediate level) 1 of 5 10/5/2009 1:14 PM Casting in C++ (intermediate level) Casting isn't usually necessary in student-level C++ code, but understanding why it's needed and the restrictions involved can help widen one's

More information

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14 Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14 Scan Converting Lines, Circles and Ellipses Hello everybody, welcome again

More information

In the figure show below, the measure of angle x is 150 since the sum of the remote interior angles is

In the figure show below, the measure of angle x is 150 since the sum of the remote interior angles is Exterior angles of a triangle An exterior angle of a triangle is equal to the sum of the remote interior angles - in other words, the two interior angles on the opposite side of the triangle. In the figure

More information

Lesson 4: Numerical Computations; Newton's method

Lesson 4: Numerical Computations; Newton's method Lesson 4: Numerical Computations; Newton's method restart; Catastrophic cancellation in the quadratic formula One case where roundoff error can be severe is if you subtract two numbers that are very close

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction MATLAB is an interactive package for numerical analysis, matrix computation, control system design, and linear system analysis and design available on most CAEN platforms

More information

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Excerpt from Art of Problem Solving Volume 1: the Basics 2014 AoPS Inc. Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

More information

John's Tutorial on Everyday Mathcad (Version 9/2/09) Mathcad is not the specialist's ultimate mathematical simulator

John's Tutorial on Everyday Mathcad (Version 9/2/09) Mathcad is not the specialist's ultimate mathematical simulator John's Tutorial on Everyday Mathcad (Version 9/2/09) Mathcad isn't: Mathcad is not the specialist's ultimate mathematical simulator Applied mathematicians may prefer the power of Mathematica Complex programs

More information

Fraction to Percents Change the fraction to a decimal (see above) and then change the decimal to a percent (see above).

Fraction to Percents Change the fraction to a decimal (see above) and then change the decimal to a percent (see above). PEMDAS This is an acronym for the order of operations. Order of operations is the order in which you complete problems with more than one operation. o P parenthesis o E exponents o M multiplication OR

More information

Lab 4. Recall, from last lab the commands Table[], ListPlot[], DiscretePlot[], and Limit[]. Go ahead and review them now you'll be using them soon.

Lab 4. Recall, from last lab the commands Table[], ListPlot[], DiscretePlot[], and Limit[]. Go ahead and review them now you'll be using them soon. Calc II Page 1 Lab 4 Wednesday, February 19, 2014 5:01 PM Recall, from last lab the commands Table[], ListPlot[], DiscretePlot[], and Limit[]. Go ahead and review them now you'll be using them soon. Use

More information

Formal Methods. CITS5501 Software Testing and Quality Assurance

Formal Methods. CITS5501 Software Testing and Quality Assurance Formal Methods CITS5501 Software Testing and Quality Assurance Pressman, R. Software Engineering: A Practitioner s Approach. Chapter 28. McGraw-Hill, 2005 The Science of Programming, David Gries, 1981

More information

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip.

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip. MAPLE Maple is a powerful and widely used mathematical software system designed by the Computer Science Department of the University of Waterloo. It can be used for a variety of tasks, such as solving

More information

Iteration. # a and b are now equal # a and b are no longer equal Multiple assignment

Iteration. # a and b are now equal # a and b are no longer equal Multiple assignment Iteration 6.1. Multiple assignment As you may have discovered, it is legal to make more than one assignment to the same variable. A new assignment makes an existing variable refer to a new value (and stop

More information

Outline. 1 If Statement. 2 While Statement. 3 For Statement. 4 Nesting. 5 Applications. 6 Other Conditional and Loop Constructs 2 / 19

Outline. 1 If Statement. 2 While Statement. 3 For Statement. 4 Nesting. 5 Applications. 6 Other Conditional and Loop Constructs 2 / 19 Control Flow 1 / 19 Outline 1 If Statement 2 While Statement 3 For Statement 4 Nesting 5 Applications 6 Other Conditional and Loop Constructs 2 / 19 If Statement Most computations require different actions

More information

Section 0.3 The Order of Operations

Section 0.3 The Order of Operations Section 0.3 The Contents: Evaluating an Expression Grouping Symbols OPERATIONS The Distributive Property Answers Focus Exercises Let s be reminded of those operations seen thus far in the course: Operation

More information

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008

More information

1 of 5 5/11/2006 12:10 AM CS 61A Spring 2006 Midterm 2 solutions 1. Box and pointer. Note: Please draw actual boxes, as in the book and the lectures, not XX and X/ as in these ASCII-art solutions. Also,

More information

Solve, RootOf, fsolve, isolve

Solve, RootOf, fsolve, isolve Solve, RootOf, fsolve, isolve Maple is capable of solving a huge class of equations: (the solution tells us that can be arbitrary). One may extract the solutions using the "[ ]" notation (we will learn

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

3 The L oop Control Structure

3 The L oop Control Structure 3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement

More information

1

1 Zeros&asymptotes Example 1 In an early version of this activity I began with a sequence of simple examples (parabolas and cubics) working gradually up to the main idea. But now I think the best strategy

More information

The mathematics you have learned about so

The mathematics you have learned about so VISUALIZING EXTRAORDINARY WAYS TO MULTIPLY LECTURE 4 The mathematics you have learned about so far has been addition ( adding quantities ); subtraction ( adding negative quantities ); and some ratios and

More information

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between MITOCW Lecture 10A [MUSIC PLAYING] PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between all these high-level languages like Lisp and the query

More information

Arithmetic expressions can be typed into Maple using the regular operators:

Arithmetic expressions can be typed into Maple using the regular operators: Basic arithmetic Arithmetic expressions can be typed into Maple using the regular operators: (type "3 + 4" and then press "[Enter]" to start the evaluation of the expression) 7 (1.1) 5 (1.2) 21 (1.3) (type

More information

1. Variables 2. Arithmetic 3. Input and output 4. Problem solving: first do it by hand 5. Strings 6. Chapter summary

1. Variables 2. Arithmetic 3. Input and output 4. Problem solving: first do it by hand 5. Strings 6. Chapter summary Topic 2 1. Variables 2. Arithmetic 3. Input and output 4. Problem solving: first do it by hand 5. Strings 6. Chapter summary Arithmetic Operators C++ has the same arithmetic operators as a calculator:

More information

ITERATION AND RECURSION 3

ITERATION AND RECURSION 3 ITERATION AND RECURSION 3 COMPUTER SCIENCE 61A June 26, 2012 1 Newton s Method Newton s method is an algorithm that is widely used to compute the zeros of functions. It can be used to approximate a root

More information

Math 2 Coordinate Geometry Part 2 Lines & Systems of Equations

Math 2 Coordinate Geometry Part 2 Lines & Systems of Equations Name: Math 2 Coordinate Geometry Part 2 Lines & Systems of Equations Date: USING TWO POINTS TO FIND THE SLOPE - REVIEW In mathematics, the slope of a line is often called m. We can find the slope if we

More information

Photoshop Tutorial: Basic Selections

Photoshop Tutorial: Basic Selections Photoshop Tutorial: Basic Selections Written by Steve Patterson, Edited by Mr. Nickel In this Photoshop tutorial, we're going to look at how to get the most out of Photoshop's basic selection tools, such

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

Parallel scan. Here's an interesting alternative implementation that avoids the second loop.

Parallel scan. Here's an interesting alternative implementation that avoids the second loop. Parallel scan Summing the elements of an n-element array takes O(n) time on a single processor. Thus, we'd hope to find an algorithm for a p-processor system that takes O(n / p) time. In this section,

More information

MITOCW watch?v=9h6muyzjms0

MITOCW watch?v=9h6muyzjms0 MITOCW watch?v=9h6muyzjms0 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

CPS122 Lecture: From Python to Java last revised January 4, Objectives: Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

Start Fred Functions. Quadratic&Absolute Value Transformations. Graphing Piecewise Functions Intro. Graphing Piecewise Practice & Review

Start Fred Functions. Quadratic&Absolute Value Transformations. Graphing Piecewise Functions Intro. Graphing Piecewise Practice & Review Honors CCM2 Unit 6 Name: Graphing Advanced Functions This unit will get into the graphs of simple rational (inverse variation), radical (square and cube root), piecewise, step, and absolute value functions.

More information

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Slide 1: Cover Welcome to lesson 3 of the db2 on Campus lecture series. Today we're going to talk about tools and scripting, and this is part 1 of 2

More information

GENERAL MATH FOR PASSING

GENERAL MATH FOR PASSING GENERAL MATH FOR PASSING Your math and problem solving skills will be a key element in achieving a passing score on your exam. It will be necessary to brush up on your math and problem solving skills.

More information

Unit 2: Accentuate the Negative Name:

Unit 2: Accentuate the Negative Name: Unit 2: Accentuate the Negative Name: 1.1 Using Positive & Negative Numbers Number Sentence A mathematical statement that gives the relationship between two expressions that are composed of numbers and

More information

Linked Lists. What is a Linked List?

Linked Lists. What is a Linked List? Linked Lists Along with arrays, linked lists form the basis for pretty much every other data stucture out there. This makes learning and understand linked lists very important. They are also usually the

More information

Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Advance mode: Auto

Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Advance mode: Auto CS 170 Java Programming 1 The Switch Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Menu-Style Code With ladder-style if-else else-if, you might sometimes find yourself writing menu-style

More information

Critical Numbers, Maximums, & Minimum

Critical Numbers, Maximums, & Minimum Critical Numbers, Maximums, & Minimum Caleb Adams October 23, 2014 Critical Numbers of Rational Functions Recall, to find a critical number, we first found the derivative of a function, then examined where

More information

Timing for Ripple Carry Adder

Timing for Ripple Carry Adder Timing for Ripple Carry Adder 1 2 3 Look Ahead Method 5 6 7 8 9 Look-Ahead, bits wide 10 11 Multiplication Simple Gradeschool Algorithm for 32 Bits (6 Bit Result) Multiplier Multiplicand AND gates 32

More information

(Refer Slide Time: 00:03:51)

(Refer Slide Time: 00:03:51) Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 17 Scan Converting Lines, Circles and Ellipses Hello and welcome everybody

More information

Computer and Programming: Lab 1

Computer and Programming: Lab 1 01204111 Computer and Programming: Lab 1 Name ID Section Goals To get familiar with Wing IDE and learn common mistakes with programming in Python To practice using Python interactively through Python Shell

More information

Chapter 3 Analyzing Normal Quantitative Data

Chapter 3 Analyzing Normal Quantitative Data Chapter 3 Analyzing Normal Quantitative Data Introduction: In chapters 1 and 2, we focused on analyzing categorical data and exploring relationships between categorical data sets. We will now be doing

More information

NetLogo Lab 3 Tutorial: Finding Peaks

NetLogo Lab 3 Tutorial: Finding Peaks NetLogo Lab 3 Tutorial: Finding Peaks You've already been exposed to the three types of agents you can give commands to in NetLogo: turtles, patches, and the observer. As you start to write your own procedures,

More information

2/22/ Transformations but first 1.3 Recap. Section Objectives: Students will know how to analyze graphs of functions.

2/22/ Transformations but first 1.3 Recap. Section Objectives: Students will know how to analyze graphs of functions. 1 2 3 4 1.4 Transformations but first 1.3 Recap Section Objectives: Students will know how to analyze graphs of functions. 5 Recap of Important information 1.2 Functions and their Graphs Vertical line

More information

1. How Mathematica works

1. How Mathematica works Departments of Civil Engineering and Mathematics CE 109: Computing for Engineering Mathematica Session 1: Introduction to the system Mathematica is a piece of software described by its manufacturers as

More information

Post Experiment Interview Questions

Post Experiment Interview Questions Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Recitation 1 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make

More information

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

More information

MITOCW ocw f99-lec07_300k

MITOCW ocw f99-lec07_300k MITOCW ocw-18.06-f99-lec07_300k OK, here's linear algebra lecture seven. I've been talking about vector spaces and specially the null space of a matrix and the column space of a matrix. What's in those

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced

More information

The C Programming Language Guide for the Robot Course work Module

The C Programming Language Guide for the Robot Course work Module The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7

More information

Stage 11 Array Practice With. Zip Code Encoding

Stage 11 Array Practice With. Zip Code Encoding A Review of Strings You should now be proficient at using strings, but, as usual, there are a few more details you should know. First, remember these facts about strings: Array Practice With Strings are

More information

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5 CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5 This fifth problem set explores the regular languages, their properties, and their limits. This will be your first foray into computability theory,

More information

Example: Which of the following expressions must be an even integer if x is an integer? a. x + 5

Example: Which of the following expressions must be an even integer if x is an integer? a. x + 5 8th Grade Honors Basic Operations Part 1 1 NUMBER DEFINITIONS UNDEFINED On the ACT, when something is divided by zero, it is considered undefined. For example, the expression a bc is undefined if either

More information

Program Development. Java Program Statements. Design. Requirements. Testing. Implementation

Program Development. Java Program Statements. Design. Requirements. Testing. Implementation Program Development Java Program Statements Selim Aksoy Bilkent University Department of Computer Engineering saksoy@cs.bilkent.edu.tr The creation of software involves four basic activities: establishing

More information

The four laws of programs

The four laws of programs Statements 1 2 The four laws of programs 3 These are like Isaac Asimov's 4 laws of robotics: 0: programs must work properly 1: programs must be readable, provided this does not conflict with the previous

More information

Maple for Math Majors. 14. Maple's Control Statements

Maple for Math Majors. 14. Maple's Control Statements Maple for Math Majors Roger Kraft Department of Mathematics, Computer Science, and Statistics Purdue University Calumet roger@calumet.purdue.edu 14.1. Introduction 14. Maple's Control Statements In order

More information

Getting Started With Excel

Getting Started With Excel Chapter 1 Getting Started With Excel This chapter will familiarize you with various basic features of Excel. Specific features which you need to solve a problem will be introduced as the need arises. When

More information