Section 1.1: Flying a UFO (continued). Conversion recipe 1)Expand abbreviations 2)Parenthesize all subexpressions that have an operator. Should end up.

Slides:



Advertisements
Similar presentations
The Order of Operations Solve: Objective: You will be able evaluate expressions using the order of operations.
Advertisements

Order of Operations Algebra Seminar
Adding and Subtracting FRACTIONS!!!!
Where We’ve Been……. Properties, Part I…….. If I say “order,” you say……… If I say “grouping,” you say……… If I say “identity,” you say……… If I keep saying.
Adding and Subtracting Fractions
Excel Lesson 4 Entering Worksheet Formulas
SLIDE SHOW INSTRUCTIONS This presentation is completely under your control. This lesson will show only one step at a time, to see the next step you must.
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 4 By Herb I. Gross and Richard A. Medeiros next.
CSC 160 Computer Programming for Non-Majors Lecture #3a: Stepper, Words, Sentences (continued) Prof. Adam M. Wittenstein
Example 2.
CSC 160 Computer Programming for Non-Majors Lecture #5: Defining Functions Prof. Adam M. Wittenstein
CSC 160 Computer Programming for Non-Majors Chapter 2: Numbers, Expressions, and Simple Programs Prof. Adam M. Wittenstein
 Monday, 9/9/02, Slide #1 CS106 Introduction to CS1 Monday, 9/9/02  QUESTIONS?? (Exercises, Lab #1, etc.)  Today:  More on float objects  C++ concept:
Session 5 of 10 Review + Multiple Sprites
Section 2.4: Errors. Common errors ● Mismatched parentheses ● Omitting space after operator or between numbers ● Putting operator between operands.
CSC 160 Computer Programming for Non-Majors Lecture #3: Calling Functions Prof. Adam M. Wittenstein
CSC 160 Computer Programming for Non-Majors Draft Chapter: The UFO Example Prof. Adam M. Wittenstein
Section 1.2: Drawing a UFO (conclusion). Last time… ● Using figure 1, we can now find a UFO’s location (using the X and Y functions). ● And, we can now.
Exercise A) Find out how tock in that figure works manually. Enter expression expressions such as (tock 0) and (tock 1) into DrScheme's Interactions.
CSC 160 Computer Programming for Non-Majors Lecture #7: Variables Revisited Prof. Adam M. Wittenstein
CSC 160 Computer Programming for Non-Majors Chapter 3: Programs are Functions Plus Variable Definitions Prof. Adam M. Wittenstein
Mr Barton’s Maths Notes
CSC 160 Computer Programming for Non-Majors Lecture #3a: Stepper, Words, Sentences Prof. Adam M. Wittenstein
CSC 160 Computer Programming for Non-Majors Lecture #5 (continued): More on Writing Functions Prof. Adam M. Wittenstein
Elementary Algebra Exam 4 Material Exponential Expressions & Polynomials.
Multiplication and Division Addition and Subtraction PracticeExponentsParenthesesHomeQuizIntroduction Objective and Standards Please Excuse My Dear Aunt.
STROUD Worked examples and exercises are in the text The logarithm segment of …
MJ2 Ch 1.6 – Algebraic Properties Quiz # 1. Bellwork Take out yesterday’s assignment and leave it on your desk for me to check! Solve and Check 1. x +
Using Your Calculator to Find the Future Value of a Single Sum with Annual Compounding 1 Dr. Craig Ruff Department of Finance J. Mack Robinson College.
Relations & Functions (x,y)y) DR ID 1. Relations & Functions Test administrator: Before administration begins, show students the front of this card and.
Section 1.1 Graphs and Graphing Utilities. Points and Ordered Pairs.
4-1 6 th grade math Exponents. Objective To write and evaluate exponential expressions Why? To prepare you for higher learning in math and science. To.
Bell Ringer = – 5 = = ÷ -2 = =6. -7 – (-7) = After you have completed the bell ringer, take out your homework!
ORDER OF OPERATIONS x 2 Evaluate the following arithmetic expression: x 2 Each student interpreted the problem differently, resulting in.
How to enter the room: 1. Greet Mrs. King at the door. A good class begins with mutual respect and recognition. 2. Retrieve a copy of the notes from the.
Order of Operations A rule of precedence in solving mathematical expressions.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
Points on a Graph Objectives After reviewing this unit you will be able to: Identify the x and y axes. Identify the origin on a graph. Identify x and y.
Topic: The Cartesian Axis/Graphing Objective: I will be able to plot given points on an axis. How do I graph (x, y) coordinates on a Cartesian axis? Today’s.
Mr. Calise Room 205 WELCOME TO ALGEBRA I! Warm-Up 1)Evaluate each expression given: w = 4, x = 5, y = 2, and z = 1 a) x + w = b) y – z = c) 2w – y =
Relations And Functions. A relation is a set of ordered pairs {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain is the set of all x.
CMSC 104, Version 8/061L10ArithmeticOps.ppt Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class.
Section 3.1 Functions Relation – a set of ordered pair of points ( x, y ). Function – a Relation where every x coordinate in the Domain corresponds to.
Order of Operations Tutorial By: Melissa Griswold Lesson Examples Assessment Use the navigation buttons on the left to begin. If you are just beginning.
Instructions for using this template. Remember this is Jeopardy, so where I have written “Answer” this is the prompt the students will see, and where.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Exponents 6262 Base: the number that you start with Exponent: tells us how many times to multiply the base. 6 x 6 b3b3 = b x b x b This is NOT the same.
TOOL CHECK. Adding and Subtracting FRACTIONS Unit 4 Lesson 4.
Transparency 6 Click the mouse button or press the Space Bar to display the answers.
AOIT Introduction to Programming Unit 2, Lesson 6 Arithmetic Operators and Operator Precedence Copyright © 2009–2012 National Academy Foundation. All rights.
Expressions and Equations 5.ATO.1 Evaluate numerical expressions involving grouping symbols (i.e., parentheses, brackets, braces). 5.ATO.2 Translate verbal.
Scientific Notation: A Review Physics 1 st 6wks. How wide is our observable universe? 210,000,000,000,000,000,000,000 miles (22 zeros) This number is.
 Most C programs perform calculations using the C arithmetic operators (Fig. 2.9).  Note the use of various special symbols not used in algebra.  The.
An Introduction to Prime Factorization by Mrs. Gress
Relations And Functions © 2002 by Shawna Haider. A relation is a set of ordered pairs. {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain.
§ 1.8 Exponents and Order of Operations. Definition of Natural Number Exponent If b is a real number and n is a natural number, b is the base and n is.
Powers and Exponents Intro to Algebra Farris.  I can write and evaluate expressions using exponents.
Functions Algebra of Functions. Functions What are functions?
Bell Ringer #3 Evaluate: Write a verbal expression:
Chapter 1 Order Of Operations
Scientific Notation Learning Goal The student will be able to:
Equivalent Linear Expressions
Introduction to Java, and DrJava part 1
MLP EVALUATION DIRECTIONS:
Lesson 3: Complex Formulas
Section 3.5 Systems of Nonlinear Systems
Algebra Concepts Section 4.2 Exponents.
1.3 Algebraic Expressions
Presentation transcript:

Section 1.1: Flying a UFO (continued)

Conversion recipe 1)Expand abbreviations 2)Parenthesize all subexpressions that have an operator. Should end up w/same number of operators, left-parentheses, and right-parentheses. 3)Move each operator to just after its own left parenthesis. (operation BEFORE operands) 3z becomes 3 * z z 2 becomes z * z 3*3+4*5 becomes ((3*3)+(4*5)) (-b+√(b 2 - 4ac))/2a becomes (((-b)+sqrt((b*b)-(4*a*c)))/(2*a))

Back to the UFO example… We know that the formula for the X-coordinate is: X = 10 * t + 20 How do we make this into a program? First, lets name the program X. Then, we need to write the expression 10 * t Use the conversion recipe.

Using the Conversion Recipe Step 1: No abbreviations. Step 2: Each operation (* and +) gets its own set of parentheses. ( ( 10 * t ) + 20 ) Step 3: Operations BEFORE operands. a) Move *( ( * 10 t ) + 20 ) b) Move +( + ( * 10 t ) 20 )

Math grammar can be confusing… 1)Some operators go between two operands; others go before one operand; some require parentheses around operand, some don’t. 2)Need PEMDAS to resolve ambiguity. 3)Sometimes there's no visible operator; defaults to multiplication. 4)(3+4) means the same as 3+4, or even ((3+4)).

…Scheme has a simpler grammar 1)All operators go before however many operands they need. 2)All subexpressions must have parentheses around them (including the operator). 3)No hidden operators; if you mean *, say it. 4)No extra parentheses allowed; exactly one pair of parentheses per operator.

Structure of a Scheme header The header is the first line of the program. It includes: The word define, which is a big marker. It says that we are defining a function, which is the real name for such algebraic formulas. The next part, (X t), which tells us two things: -the name of the expression (X in this case) and -the name of the parameter(s), which are the variables on which a program depends (t in this case)

Structure of a Scheme program A program has two parts: –the header define(define expression name(X name(s) of variable(s)t) –the body the actual expression(+ (* 10 t) 20)) It is very important to make sure the parentheses match: that is, you need the same number of open parentheses and closed parenthesis.

Math vs. Scheme Here is the math way to find the x- coordinate: X = 10 · t + 20 And here is the Scheme way: (define (X t) (+ (* 10 t) 20))

Using a Scheme program Now that we have defined the function in Scheme, we must learn to use it. As we just discussed, the definition tells us that X depends on t. This means that when we want to use X: - we must supply a value for t Then -the Scheme program replies with the value of X. For example, typing (X 0) gives the value of X when t = 0. What is that value?

How does Scheme get 20? DrScheme, which is basically a calculator for Scheme functions, then evaluates this expression for us, using the rules from algebra that we know so well. 0 is one instance of the program. Scheme then finds out that in that instance, X = 20. To see how Scheme does this, we can use the Stepper.

Using the stepper DrScheme provides a Stepper tool that shows how a complex expression is evaluated, step-by-step. For example, take the expression (+ 2 (* 3 4)) Just as with PEMDAS, DrScheme must evaluate the (* 3 4) expression first to get 12. Then, it can evaluate (+ 2 12) to get 14.

Using the stepper To use the Stepper tool, put the expression(s) you want to evaluate into DrScheme's top area, the definitions window, then click the Step button:

Using the stepper Click next and you will get the answer of 14.

Using the two windows The top area, the definitions window, is for defining new programs (like X and Y). The bottom area, the interactions window, is for using programs once they are defined. Fortunately, Dr. Scheme already has some programs written inside of it for us to use. Examples are +, -, *, and /. To use the + program, like when we find 3 + 4, type it into the interactions window the Scheme way: (+ 3 4). After hitting enter, you get 7.

We define programs in the Definitions Window. (define (X t) (+ (* 10 t) 20)) We then test them in the Interactions Window. > (X 0) 20 > (X 1) 30 Using the two windows

Exercise 1.1.3: “Y” Program The game program will need to do several things, including: The game program will need to do several things, including: - figure out the X-coordinate - figure out the Y-coordinate - displaying the UFO and shots on the screen We already have a program for X. We already have a program for X. Now, write a program for Y. (Hint: look back to the work you did in exercise 1.1.1) Now, write a program for Y. (Hint: look back to the work you did in exercise 1.1.1)

Next time… Drawing the UFO on a canvas Today we worked with numbers to determine the location of the UFO. However we are not yet able to actual see the UFO at its location. We will see how to do that next time.