Object Semantics Lecture 2

Size: px
Start display at page:

Download "Object Semantics. 6.170 Lecture 2"

Transcription

1 Object Semntics Lecture 2 The objectives of this lecture re to: to help you become fmilir with the bsic runtime mechnism common to ll object-oriented lnguges (but with prticulr focus on Jv): vribles, object references, ssignments, mutbility, nd so on; to introduce digrmmtic nottion, object digrms for describing snpshots (tht is, prticulr configurtions of objects in the hep); 1 to mke you wre, in pssing, of some tricky issues tht we ll return to lter in more detil, nd which turn out to be of fundmentl importnce: equlity, rep invrints nd exposure. When you ve completed this mteril, you should hve solid grsp of wht hppens when Jv code executes, so tht you cn predict wht some code will do without running it. 1 Vribles, References nd Objects Some types of objects cn be creted with literls. Wht hppens when you run this? 1. String = "zeeb"; 2. String b =.touppercse (); 3. System.out.println (b); It prints ZEEB. Sttement 2 is cll to the method touppercse. The method hs receiver. The cll results in the cretion of fresh string tht is then bound to the vrible b. We cn drw the result of the first two sttements s n object digrm, showing tht is reference to n object of type String (nd not the string itself, or slot tht holds it); similrly for b. b "zeeb" "ZEEB" 1 Wht does this do? 1. String = "zeeb"; 2..toUpperCse (); 3. System.out.println (); Lter, we will introduce object models tht re fr more useful nd which describe sets of snpshots. 1

2 It prints zeeb. Sttement 2 cretes fresh string tht gets thrown wy since it is bound to no vrible. The string object referenced by is not chnged: strings re immutble. Wht bout this? String = "zeeb"; =.touppercse (); System.out.println (); Agin, no object chnges. But is mde to refer to the new object by the ssignment in Sttement 2, so the result is ZEEB. "zeeb" "ZEEB" 2 Alising, Mutbility nd Reference Equlity Jv provides vriety of collections s prt of its stndrd librry. A vector is like n rry, but it cn grow nd shrink dynmiclly. An exmple of using vector: 1. Vector v = new Vector (); 2. Vector k = v; 3. String = "zeeb"; 4. v.dd (); 5. k.dd (.touppercse()); 6. System.out.println (v.lstelement ()); The method lstelement is like the string method touppercse: it hs no effect on the receiver nd returns reference to n object (in this cse, the lst element of the vector v). The method dd, on the other hnd, tkes n rgument the string. Unlike touppercse, the method dd does not return n object, but chnges or muttes its receiver object. Vectors, unlike strings, cn chnge, nd re thus sid to be mutble. The code bove prints ZEEB, since fter Sttement 2 the two vribles k nd v re nmes for the sme vector object: they re sid to be lises. The clls to dd mutte the one vector object, first dding the object for the lower cse string, then the upper cse string. The chnges re visible through both nmes, so in Sttements 4 to 6 we could ctully permute the nmes k nd v without ny chnge in behvior. Here is the object digrm: v k (Vector) elts[0] "zeeb" "ZEEB" elts[1] 2

3 Alising is pervsive in lnguges like Jv, nd very useful. But it dds lot of complexity. For one thing, it breks the rule tht sttement ffects only the vribles it mentions. Just becuse v isn t mentioned in Sttement 5 doesn t men tht it won t ffect the result of sttement 6 which mentions only v nd not k. How cn we observe the lising more directly? By testing equlity: Vector v = new Vector (); Vector k = v; if (v == k) System.out.println ("sme"); System.out.println ("different"); which results in sme being printed. The built-in == test tells you whether two references re for the sme object, so it s often clled test of reference equlity. Wht does this do? Vector v = new Vector (); Vector k = new Vector (); if (v == k) System.out.println ("sme"); System.out.println ("different"); It prints different, becuse v nd k re distinct objects. It s fundmentl property of constructors tht the objects they return relly re fresh. In fct, the grbge collector cn recycle n object, but only if there is no reference to it still round. This ensures tht even if objects re recycled, we cn never tell. A puzzle: wht does this do? String = "zeeb"; String b = "zeeb"; if ( == b) System.out.println ("sme"); System.out.println ("different"); Strngely, this prints sme, becuse the Jv virtul mchine utomticlly interns string literls: if it cn tell tht two string literls hve the sme sequence of chrcters, it only lloctes one object. You d be right to think this is bit confusing; it s performnce optimiztion. In fct, it s very bd form to test reference equlity of immutble objects, unless you re doing something subtle with memory mngement. Argubly it s design defect of Jv tht you cn even observe whether two immutble objects re the sme or not. So how should you compre two immutble objects? With n equls method. The String clss provides method equls tht tells you whether two strings contin the sme sequence of chrcters or not. This code String = "zeeb"; String b =.touppercse (); 3

4 if (b.equls ("ZEEB")) System.out.println ("sme chrcters"); System.out.println ("different chrcters"); prints sme chrcters. When we study inheritnce, you ll lern tht every clss utomticlly inherits n equls method, so you might think you don t need to write one. But it s lmost never wht you wnt, so whenever you design clss, one of the first things you ll need to figure out is when two objects of the clss should be considered equl to one nother. Here re some questions: Would you expect tht generlly x == y implies x.equls (y)? Yes, it should. Becuse the equls method cn be user-defined, just like ny other method, you could mke it behve in ny wy you wnted. On mutble type, it might even mutte the object! But tht would be disstrous: there s generic contrct tht clients expect equls to obey. More on this lter. Why would lnguge hve immutble types? Becuse lising is complicted, nd when you use immutble types, the issue doesn t rise. Also, code built with immutble types cn sometimes be more efficient. So if immutble types re so much simpler, why hve mutble types? Becuse muttion gives very useful form of modulrity: it llows you to mke locl chnges to structure. And muttion is often nturl wy to model entities in the rel world: trnsction on bnk ccount chnges it; it doesn t produce new bnk ccount. 3 Null References Wht does this do? String = null; System.out.println (); It prints null. The keyword null denotes vlue tht cn be tken on by n object reference. It mens tht the reference does not in fct refer to ny object. There is no null object! But note tht this code 1. String = null; 2. String b =.touppercse (); 3. System.out.println (b); behves quite differently. It throws NullPointerException on Sttement 2. We ll lern bout exceptions lter, but for now, ll you need to understnd is tht Sttement 2 filed, when the expression.touppercse() ws evluted. Wht s the difference? The receiver to method cll cn never be null, becuse it identifies the object tht receives the cll nd tht hs to be some object. So.toUpperCse() fils when is null. But in the previous exmple, System.out.println() is OK when is null, since reference is n rgument, nd this is specil kind of method (relly just plin old procedure) tht doesn t hve receiver. 4

5 You cn write method tht tests whether n rgument is null nd does something pproprite. Dereferencing null is common progrmming mistke in Jv. To void it, you cn check whether reference is null before you ttempt to cll method. In generl, rther thn ctching nulls nd treting them specilly, it s better to void creting null references in the first plce. You ll lern bout tht when we discuss representtion invrints. Sometimes you cn t void it, nd then it s importnt to document where the null references my occur. Tht s one reson specifictions re importnt: they cn spre you runtime errors nd unnecessry checks. Here re some questions: In generl, would you expect.equls (b) to be substitutble for b.equls ()? No, becuse when is null nd b is not, the first will throw n exception, nd the second will (usully) return flse. OK, smrty pnts, leve nulls lone. Would you then expect.equls (b) nd b.equls () to hve the sme effect? Yes, you would. In fct, this property of the equls method clled symmetry is demnded by Jv s object contrct. We ll see lter when we study equlity in depth wht other properties re required, nd how esy it is to mess up nd write n equls method tht does not hve these properties. 4 User-defined Clsses nd Fields Let s mke some objects of our own: clss Trns { int mount; Dte dte; } This code declres clss, kind of templte for mking objects. These objects re going to represent trnsctions in bnking system. Ech object hs n integer mount (which my be negtive for withdrwl), nd dte/time stmp to mrk the moment t which the trnsction occurred. The clss declres two fields or instnce vribles, mount nd dte. Ech object of the clss will contin two references, one to n integer nd one to dte. The type Dte is clss from the Jv librry; it s predefined like String (but not prt of the lnguge definition the wy String is). The type int is rther strnge best. It s not clss t ll, but primitive type. Vribles or fields of type int don t hold references to integer objects; they hold the integers themselves. You my think it bit jrring tht n object-oriented lnguge hs this rther unobject-oriented notion in it (nd mny people shre your opinion). Sometimes we ll ctully need n integer tht s n object, nd in tht cse we cn use the clss Integer from the Jv librry. How do you get from n int to n Integer nd bck? To crete n Integer, you use constructor: int_i = 5; Integer obj_i = new Integer (i); nd to extrct the primitive integer from n integer object, you cll method: 5

6 int i = obj_i.intvlue(); A little cumbersome, so tht s one reson people don t like this design. If we run this code: 1. Trns t = new Trns (); 2. t.mount = 20; 3. t.dte = new Dte (); fresh object gets creted, nd its fields re set, resulting in this configurtion: t dte (Dte) (Trns) mount The expression on the right-hnd side of Sttement 1 is cll to constructor: it mkes new object with defult vlues for the fields. In this cse, it cretes Trns object with zero for the mount nd null for dte. The Sttement 2 is clled setter: it sets the vlue of the field mount of the object referred to by t. Sttement 3 hs nother constructor cll on the right; creting new Dte, which by defult cretes Dte object representing the moment t which the object is itself creted. But it s lso setter: it sets the dte field of t to point to this new dte User-defined Constructors So we ve succeeded in mking Trns object representing deposit of twenty dollrs t this moment in time. The wy we did it creting n uninitilized object nd then setting its fields is not good one, however. We ll wnt our trnsctions to be well-formed; for exmple we won t wnt to hve trnsctions tht don t hve dtes. And perhps we ll wnt every trnsction to hve non-zero mount. Lter, we ll study these kinds of invrints in much more depth. For now, just observe tht immeditely fter Sttement 1 we hve trnsction object tht is not well formed. When n object is creted, its fields re initilized to defult vlues: null for object references, nd zero for integers. So t.mount will be zero, nd t.dte will be null. These defult vlues re rrely wht you wnt; fter ll, which vlues mke sense will depend on the problem we re trying to solve. In this cse, you d hve to know something bout bnking to know tht trnsction of zero dollrs is ill-formed. Is it big del tht there s bogus trnsction object hnging round between Sttements 1 nd 2? Yes, it is, nd here s why. We d like the responsibility for ensuring tht objects of the clss Trns re well formed to be hndled entirely within the Trns clss. In our progrm, you need to check not only the code of the clss, but lso the code tht uses the clss. At this scle, it s not disster. But in much lrger progrm, you need s much modulrity s you cn get, confining tricky spects of the progrm s much s possible to smll res of the code. To solve this problem, we declre our own constructor: clss Trns { int mount; 6

7 } Dte dte; Trns (int, Dte d) {mount = ; dte = d;} This constructor tkes n mount nd dte s rguments, nd cretes trnsction object with tht mount nd dte. If I d wnted to ensure tht the mount of trnsction is non-zero, I could hve dded check tht threw n exception if the mount ws zero; we ll see how to do tht lter. A peculir, but useful, property of constructors is tht hving defined our own constructor, the defult constructor the one tht just initilizes ech field to defult vlues becomes no longer vilble. So Sttement 1 will no longer compile. Insted, we cn write Trns t = new Trns (20, new Dte ()); nd tht one line of code will hve the effect tht Sttements 1 to 3 hd previously. (We hven t fully solved the problem of modulrizing the invrint of Trns, by the wy. You cn still mess up Trns object by setting its dte field to null from outside, for exmple. The first step to prevent this is to mke use of Jv s ccessibility mechnisms: we cn mke the fields privte so they cn t be red or written from outside the clss. In fct, this turns out not to be enough, s we ll lern when we study dt bstrction.) 6 Conclusion Now we ve seen ll the key notions for how objects re mnipulted in n object-oriented lnguge. We ve seen how they re creted; how references re bound to objects; nd how their fields re set. We ve mentioned the two fundmentl kinds of equlity reference equlity (tested with ==) nd object equlity (tested with n equls method bout which we ll hve much more to sy lter. These mechnisms comprise one importnt prt of wht it mens to be object oriented. 7

Review of objects and variables in Java

Review of objects and variables in Java CMSC 331 Principles of progrmming lnguges Reiew of ojects nd riles in J Vriles nd Ojects wht hppens when you run this? String = ; System.out.println (); wht is? string literl tht elutes to String oject

More information

Lecture for Week 14 (Secs ) Definite Integrals and the Fundamental Theorem

Lecture for Week 14 (Secs ) Definite Integrals and the Fundamental Theorem Lecture for Week 14 (Secs. 6.3 4) Definite Integrls nd the Fundmentl Theorem 1 Integrl clculus the second hlf of the subject, fter differentil clculus hs two spects: 1. Undoing differentition. This is

More information

Systems of Equations

Systems of Equations III-3 Systems of Equtions Multiple Equtions with Multiple Unknowns: The generl rule tht you need to be wre of is tht to solve for two unknowns, you need two independent equtions contining those two unknowns

More information

1 What You Need To Know About Basic Maths

1 What You Need To Know About Basic Maths 1 Wht You Need To Know About Bsic Mths Before we cn strt on ny of the more interesting stuff, I thought I d mke sure tht everyone hs the bsic mthemticl bckground necessry to red nd understnd everything

More information

REVIEW OF THE DEFINITE AND INDEFINITE INTEGRALS NORTHERN ILLINOIS UNIVERSITY, MATH 230

REVIEW OF THE DEFINITE AND INDEFINITE INTEGRALS NORTHERN ILLINOIS UNIVERSITY, MATH 230 REVIEW OF THE DEFINITE AND INDEFINITE INTEGRALS NORTHERN ILLINOIS UNIVERSITY, MATH 230 This is quick review of the definite nd indefinite integrl from first semester clculus. We strt with the notion of

More information

11.2 Logarithmic Functions

11.2 Logarithmic Functions .2 Logrithmic Functions In the lst section we delt with the eponentil function. One thing tht we notice from tht discussion is tht ll eponentil functions pss the horizontl line test. Tht mens tht the eponentil

More information

The next type of numbers we generally come to understand are fractions, but we ll put these on hold for now.

The next type of numbers we generally come to understand are fractions, but we ll put these on hold for now. The Rel Number Line nd Types of Rel Numbers Most people s first understnding of numbers reltes to wht we mth-type people cll counting numbers or more formlly nturl numbers. These re the numbers we use

More information

COS 126 General Computer Science Fall Written Exam 2

COS 126 General Computer Science Fall Written Exam 2 COS 126 Generl Computer Science Fll 2016 Written Exm 2 This exm hs 9 questions (including question 0) worth totl of 70 points. You hve 50 minutes. Write ll nswers inside the designted spces. Policies.

More information

Integrals as Net Area Calculus 11, Veritas Prep.

Integrals as Net Area Calculus 11, Veritas Prep. Integrls s Net Are Clculus 11, Verits Prep. Prolems 1. Using Prt II of the FTC, clculte 12 12 5 x 2 dx. Then clculte x 2 dx. Compre nd contemplte your results. (Note tht 5 I m not sking you here to find

More information

Unit 4 The Definite Integral

Unit 4 The Definite Integral Unit 4 The Definite Integrl We know wht n indefinite integrl is: the generl ntiderivtive of the integrnd function. There is relted (lthough in some wys vstly different) concept, the definite integrl, which

More information

G THE DEFINITE INTEGRAL

G THE DEFINITE INTEGRAL Theory Supplement Section G 35 G THE DEFINITE INTEGRAL Recll tht if f is continuous on [, b] the definite integrl is given by limit of left or right sums: n f(x) dx = lim f(x i ) x = lim n i= n i= f(x

More information

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus Unit #9 : Definite Integrl Properties, Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl

More information

PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY

PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY MAT 0630 INTERNET RESOURCES, REVIEW OF CONCEPTS AND COMMON MISTAKES PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY Contents 1. ACT Compss Prctice Tests 1 2. Common Mistkes 2 3. Distributive

More information

ECE 468/573 Midterm 1 September 30, 2011

ECE 468/573 Midterm 1 September 30, 2011 ECE 468/573 Midterm 1 September 30, 2011 Nme: Purdue emil: Plese sign the following: I ffirm tht the nswers given on this test re mine nd mine lone. I did not receive help from ny person or mteril other

More information

Pointers in C. Address vs. Value. Another Need for Addresses. Executing the Swap Function

Pointers in C. Address vs. Value. Another Need for Addresses. Executing the Swap Function Address vs. Vlue Sometimes we wnt to del with the ddress of memory loction, rther thn the vlue it contins Pointers in C Bsed on slides McGrw-Hill Additionl mteril 200/2005 Lewis/Mrtin Modified y Din Plseti

More information

a, a 1, and x is any real

a, a 1, and x is any real MA 131 Lecture Notes Eponentil Functions, Inverse Functions, nd Logrithmic Functions Eponentil Functions We sy tht unction is n lgebric unction i it is creted by combintion o lgebric processes such s ddition,

More information

Chapter 6 Solving equations

Chapter 6 Solving equations Chpter 6 Solving equtions Defining n eqution 6.1 Up to now we hve looked minly t epressions. An epression is n incomplete sttement nd hs no equl sign. Now we wnt to look t equtions. An eqution hs n = sign

More information

Mathematics for Chemists 2 Lecture 1: Integral calculus I. Indefinite and definite integrals, basic calculation of integrals

Mathematics for Chemists 2 Lecture 1: Integral calculus I. Indefinite and definite integrals, basic calculation of integrals Mthemtics for Chemists 2 Lecture 1: Integrl clculus I Indefinite nd definite integrls, sic clcultion of integrls Johnnes Kepler University Summer semester 2012 Lecturer: Dvid Sevill Integrl clculus I 1/19

More information

Session 37 Introduction to Integers. How may we compare the values of the following two accounts?

Session 37 Introduction to Integers. How may we compare the values of the following two accounts? Session 7 Introduction to Integers How my we compre the vlues of the following two ccounts? Sm hd two ccounts, svings ccount nd lon. She hd certificte of deposit worth $4,60 nd cr lon of $8,290. Which

More information

Inf1A: Non-deterministic Finite State Machines

Inf1A: Non-deterministic Finite State Machines Lecture 3 InfA: Non-deterministic Finite Stte Mchines 3. Introduction In this lecture we del with non-deterministic Finite Stte Mchines, clss of mchines which re generliztion of deterministic Finite Stte

More information

Polynomial Functions. Polynomial functions in one variable can be written in expanded form as ( )

Polynomial Functions. Polynomial functions in one variable can be written in expanded form as ( ) Polynomil Functions Polynomil functions in one vrible cn be written in expnded form s n n 1 n 2 2 f x = x + x + x + + x + x+ n n 1 n 2 2 1 0 Exmples of polynomils in expnded form re nd 3 8 7 4 = 5 4 +

More information

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER /2017

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER /2017 ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS MATH00030 SEMESTER 206/207 DR. ANTHONY BROWN 7.. Introduction to Integrtion. 7. Integrl Clculus As ws the cse with the chpter on differentil

More information

Conceptual Explanations: Exponents

Conceptual Explanations: Exponents Conceptul Eplntions: Eponents An eponent mens repeted multipliction. For instnce, 0 6 mens 0 0 0 0 0 0, or,000,000. You ve probbly noticed tht there is logicl progression of opertions. When you dd the

More information

Objects and Classes. To beautify life is to give it an object. José Martí, On Oscar Wilde, Rational Numbers

Objects and Classes. To beautify life is to give it an object. José Martí, On Oscar Wilde, Rational Numbers C H A P T E R! Objects nd Clsses The Art nd Science of ERIC S. ROBERTS Jv An Introduction to Computer Science To beutify life is to give it n object. José Mrtí, On Oscr Wilde, 888 Chpter Objects nd Clsses

More information

Exponentiation: Theorems, Proofs, Problems Pre/Calculus 11, Veritas Prep.

Exponentiation: Theorems, Proofs, Problems Pre/Calculus 11, Veritas Prep. Exponentition: Theorems, Proofs, Problems Pre/Clculus, Verits Prep. Our Exponentition Theorems Theorem A: n+m = n m Theorem B: ( n ) m = nm Theorem C: (b) n = n b n ( ) n n Theorem D: = b b n Theorem E:

More information

CALCULUS I (in a nutshell)

CALCULUS I (in a nutshell) We ve spent this semester lerning two min concepts: 1. DERIVATION 2. INTEGRATION CALCULUS I (in nutshell) DERIVATION: The derivtive of function f(x) with respect to the vrible x is FUNCTION denoted f (x)

More information

Use Geometry Expressions to create a more complex locus of points. Find evidence for equivalence using Geometry Expressions.

Use Geometry Expressions to create a more complex locus of points. Find evidence for equivalence using Geometry Expressions. Lerning Objectives Loci nd Conics Lesson 3: The Ellipse Level: Preclculus Time required: 120 minutes In this lesson, students will generlize their knowledge of the circle to the ellipse. The prmetric nd

More information

Quadratic Equations. Math 99 N1 Chapter 8

Quadratic Equations. Math 99 N1 Chapter 8 Qudrtic Equtions Mth 99 N1 Chpter 8 1 Introduction A qudrtic eqution is n eqution where the unknown ppers rised to the second power t most. In other words, it looks for the vlues of x such tht second degree

More information

Lecture 18 : Wednesday May 14th

Lecture 18 : Wednesday May 14th Lecture 8 : Wednesdy My 4th jcques@ucsd.edu 8. Are nd rc-length in polr co-ordintes The rc length of the curve r = f(θ) for α θ β is given by the formul β α f (θ) + f(θ) dθ. We lso stted the formul β x

More information

0.1. Definite Integrals and Area. Recall that we write a definite integral of f(x) from a to b as b

0.1. Definite Integrals and Area. Recall that we write a definite integral of f(x) from a to b as b CHAPTER 5 We use derivtives to find the rte of chnge of function. For exmple, if you hve function telling you the position of rocketship, you could tke the derivtive to find its velocity. Frequently, however,

More information

Math 135 Circles and Completing the Square Examples

Math 135 Circles and Completing the Square Examples Mth 135 Circles nd Completing the Squre Exmples A perfect squre is number such tht = b 2 for some rel number b. Some exmples of perfect squres re 4 = 2 2, 16 = 4 2, 169 = 13 2. We wish to hve method for

More information

Addition and subtraction of rational expressions

Addition and subtraction of rational expressions Lecture 5. Addition nd subtrction of rtionl expressions Two rtionl expressions in generl hve different denomintors, therefore if you wnt to dd or subtrct them you need to equte the denomintors first. The

More information

MATLAB: M-files; Numerical Integration Last revised : March, 2003

MATLAB: M-files; Numerical Integration Last revised : March, 2003 MATLAB: M-files; Numericl Integrtion Lst revised : Mrch, 00 Introduction to M-files In this tutoril we lern the bsics of working with M-files in MATLAB, so clled becuse they must use.m for their filenme

More information

Taylor Polynomials with Error Term

Taylor Polynomials with Error Term Tylor Polynomils with Error Term The functions e x, sinx, / x, etc re nice functions but they re not s nice s polynomils. Specificlly polynomils cn be evluted completely bsed on multipliction, subtrction

More information

WEEK #9 : Definite Integral Properties; Fundamental Theorem of Calculus

WEEK #9 : Definite Integral Properties; Fundamental Theorem of Calculus WEEK #9 : Definite Integrl Properties; Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl

More information

Example 27.1 Draw a Venn diagram to show the relationship between counting numbers, whole numbers, integers, and rational numbers.

Example 27.1 Draw a Venn diagram to show the relationship between counting numbers, whole numbers, integers, and rational numbers. 2 Rtionl Numbers Integers such s 5 were importnt when solving the eqution x+5 = 0. In similr wy, frctions re importnt for solving equtions like 2x = 1. Wht bout equtions like 2x + 1 = 0? Equtions of this

More information

MA Lesson 21 Notes. **It is important to understand that a logarithm is an exponent!**

MA Lesson 21 Notes. **It is important to understand that a logarithm is an exponent!** MA 15910 Lesson 1 Notes ( x5) How would person solve n eqution with vrible in n exponent, such s 9? (We cnnot re-write this eqution esily with the sme bse.) A nottion ws developed so tht equtions such

More information

The Riemann Integral. Chapter Definition of the Riemann integral

The Riemann Integral. Chapter Definition of the Riemann integral Chpter The Riemnn Integrl now of some universities in Englnd where the Lebesgue integrl is tught in the first yer of mthemtics degree insted of the Riemnn integrl, but now of no universities in Englnd

More information

The Traditional Definition of the Integral

The Traditional Definition of the Integral The Trditionl Definition of the Integrl y 2 y = f ( ) 1 2 3 4 5 5 2 f ( ) d = lim n n f( i) i=1 where = 5 2 n nd i lies somewhere between 2+(i 1) nd 2 + i 1 Wht Is n Integrl? An integrl is process ( blck

More information

Algebra Review. How well do you remember your algebra?

Algebra Review. How well do you remember your algebra? Algebr Review How well do you remember your lgebr? 1 The Order of Opertions Wht do we men when we write + 4? If we multiply we get 6 nd dding 4 gives 10. But, if we dd + 4 = 7 first, then multiply by then

More information

Linear Functions. (1) Let F denote the Fahrenheit temperature and C the Celsius temperature of an object. F and C are related by

Linear Functions. (1) Let F denote the Fahrenheit temperature and C the Celsius temperature of an object. F and C are related by Liner Functions A. Definition nd Exmples A function f is liner if it cn be expressed in the form f ( x) = mx + b where m nd b re constnts nd x is n rbitrry member of the domin of f. Often the reltionship

More information

Protocol Analysis. 17-654/17-764 Analysis of Software Artifacts Kevin Bierhoff

Protocol Analysis. 17-654/17-764 Analysis of Software Artifacts Kevin Bierhoff Protocol Anlysis 17-654/17-764 Anlysis of Softwre Artifcts Kevin Bierhoff Tke-Awys Protocols define temporl ordering of events Cn often be cptured with stte mchines Protocol nlysis needs to py ttention

More information

1. Recursion. Recursive Data Structures. 2. Recursive Data Structures. CITS2200 Data Structures and Algorithms

1. Recursion. Recursive Data Structures. 2. Recursive Data Structures. CITS2200 Data Structures and Algorithms 1. Recursion CITS2200 Dt Structures nd Algorithms Topic 3 Recursive Dt Structures Review of recursion: mthemticl functions Recursive dt structures: Stcks nd Lists Implementing linked stcks in Jv Jv nd

More information

COMP 250 Fall priority queues, heaps 1 Oct 31, 2016

COMP 250 Fall priority queues, heaps 1 Oct 31, 2016 Priority Queue Recll the definition of queue. It is collection where we remove the element tht hs been in the collection for the longest time. Alterntively stted, we remove the element tht first entered

More information

GMAT Word Problems: Fundamentals (Excerpt)

GMAT Word Problems: Fundamentals (Excerpt) GMAT Word Problems: Fundmentls (Excerpt) Jeff Sckmnn / GMAT HACKS Jnury 2013 Contents 1 Introduction 2 2 Difficulty Levels 3 3 Problem Solving 4 4 Dt Sufficiency 6 5 Answer Key 8 6 Explntions 9 1 1 Introduction

More information

5 Techniques of Integration

5 Techniques of Integration Clculus II (prt ): Techniques of Integrtion (by Evn Dummit,, v..5) Contents 5 Techniques of Integrtion 5. Bsic Antiderivtives............................................. 5. Substitution..................................................

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 25 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 25 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 25 September 2015 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

The Riemann Integral

The Riemann Integral The Riemnn Integrl July 24, 2007 1 pper nd lower sums A prtition of closed intervl [, b] is subset P = {x 0, x 1,...,x n } of [, b] with = x 0 < x 1 < < x n = b. A prtition divides the intervl [, b] into

More information

SOLUTIONS TO HOMEWORK #1, MATH 54 SECTION 001, SPRING 2012

SOLUTIONS TO HOMEWORK #1, MATH 54 SECTION 001, SPRING 2012 SOLUTIONS TO HOMEWOK #, MATH 5 SECTION, SPING JASON FEGUSON. Bewre of typos. In fct, your solutions my e etter thn mine.. Some prolems hve scrtch work nd solutions. The scrtch work sys how I cme up with

More information

1. The leves re either lbeled with sentences in ;, or with sentences of the form All X re X. 2. The interior leves hve two children drwn bove them) if

1. The leves re either lbeled with sentences in ;, or with sentences of the form All X re X. 2. The interior leves hve two children drwn bove them) if Q520 Notes on Nturl Logic Lrry Moss We hve seen exmples of wht re trditionlly clled syllogisms lredy: All men re mortl. Socrtes is mn. Socrtes is mortl. The ide gin is tht the sentences bove the line should

More information

10.5 Graphing Quadratic Functions

10.5 Graphing Quadratic Functions 0.5 Grphing Qudrtic Functions Now tht we cn solve qudrtic equtions, we wnt to lern how to grph the function ssocited with the qudrtic eqution. We cll this the qudrtic function. Grphs of Qudrtic Functions

More information

hp calculators HP 10s Solving Problems Involving Fractions Basic Concepts Fractions on the HP 10s Practice Working Problems Involving Fractions

hp calculators HP 10s Solving Problems Involving Fractions Basic Concepts Fractions on the HP 10s Practice Working Problems Involving Fractions Bsic Concepts Frctions on the HP 10s Prctice Working Problems Involving Frctions Bsic concepts Those numbers tht cn be written s one integer over nother, i.e., (b cn t be zero) re clled rtionl numbers.

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson) Dept. of Computer

More information

DEFINITE INTEGRALS, FUNDAMENTAL THEOREM OF CALCULUS, ANTIDERIVATIVES

DEFINITE INTEGRALS, FUNDAMENTAL THEOREM OF CALCULUS, ANTIDERIVATIVES DEFINITE INTEGRALS, FUNDAMENTAL THEOREM OF CALCULUS, ANTIDERIVATIVES MATH 152, SECTION 55 (VIPUL NAIK) Corresponding mteril in the book: Section 5.3, 5.4 Difficulty level: Hrd. Wht students should definitely

More information

LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES

LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES DAVID WEBB CONTENTS Liner trnsformtions 2 The representing mtrix of liner trnsformtion 3 3 An ppliction: reflections in the plne 6 4 The lgebr of

More information

Newton's Laws and Equation of Motion

Newton's Laws and Equation of Motion Newton's Lws nd Eqution of Motion Introduction Newton s lws consist of the lw of inerti, the lw of motion, nd the lw of ction nd rection. The first lw depicts tht if there is no externl effect, n object

More information

Operations with Polynomials

Operations with Polynomials 38 Chpter P Prerequisites P.4 Opertions with Polynomils Wht you should lern: Write polynomils in stndrd form nd identify the leding coefficients nd degrees of polynomils Add nd subtrct polynomils Multiply

More information

Chapter 2 Section 6 Lesson Squares, Square Roots, and Absolute Value

Chapter 2 Section 6 Lesson Squares, Square Roots, and Absolute Value Chpter Section 6 Lesson Squres, Squre Roots, nd Absolute Vlue Introduction This lesson explins squred numbers, the squre root, nd the ide of bsolute vlue. Squred Numbers To squre number mens to multiply

More information

1 Numerical Solution to Quadratic Equations

1 Numerical Solution to Quadratic Equations cs42: introduction to numericl nlysis 09/4/0 Lecture 2: Introduction Prt II nd Solving Equtions Instructor: Professor Amos Ron Scribes: Yunpeng Li, Mrk Cowlishw Numericl Solution to Qudrtic Equtions Recll

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

Factoring Polynomials

Factoring Polynomials Fctoring Polynomils Some definitions (not necessrily ll for secondry school mthemtics): A polynomil is the sum of one or more terms, in which ech term consists of product of constnt nd one or more vribles

More information

Lecture Notes on Differentiation

Lecture Notes on Differentiation Lecture Notes on Differentition A tngent line to function t point is the line tht best pproximtes the function t tht point better thn ny other line. The slope of the function t given point is the slope

More information

Digital Signal Input and Output

Digital Signal Input and Output DIO-1 Purpose Digitl Signl Input nd Output To introduce the digitl input nd output functions of the OOPic microcontroller To prctice reding logic level signls from n input port To prctice sending logic

More information

Exponents base exponent power exponentiation

Exponents base exponent power exponentiation Exonents We hve seen counting s reeted successors ddition s reeted counting multiliction s reeted ddition so it is nturl to sk wht we would get by reeting multiliction. For exmle, suose we reetedly multily

More information

Curve Sketching. 96 Chapter 5 Curve Sketching

Curve Sketching. 96 Chapter 5 Curve Sketching 96 Chpter 5 Curve Sketching 5 Curve Sketching A B A B A Figure 51 Some locl mximum points (A) nd minimum points (B) If (x, f(x)) is point where f(x) reches locl mximum or minimum, nd if the derivtive of

More information

4x 2-2x 3. Chapter 2: Variable Expressions

4x 2-2x 3. Chapter 2: Variable Expressions Chpter : Vrible Expressions Expressions (contin no sign) : An expressionis one or numbers or vribles hving some mthemticl opertions done on them. Numericl Expressions: 3 + 5 3(4) / 5-1 4 Expressions cn

More information

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2011 - Final Exam

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2011 - Final Exam 1./1.1 Introduction to Computers nd Engineering Problem Solving Fll 211 - Finl Exm Nme: MIT Emil: TA: Section: You hve 3 hours to complete this exm. In ll questions, you should ssume tht ll necessry pckges

More information

LECTURE 3: DOT PRODUCT CONTINUED AND THE CROSS PRODUCT

LECTURE 3: DOT PRODUCT CONTINUED AND THE CROSS PRODUCT LECTURE 3: DOT PRODUCT CONTINUED AND THE CROSS PRODUCT DAGAN KARP ABSTRACT. In this lecture we ll conclude our initil study of the dot product, nd begin our study of the cross product. 1. DOT PRODUCT CONTINUED

More information

Net Change and Displacement

Net Change and Displacement mth 11, pplictions motion: velocity nd net chnge 1 Net Chnge nd Displcement We hve seen tht the definite integrl f (x) dx mesures the net re under the curve y f (x) on the intervl [, b] Any prt of the

More information

Recitation 2: The Derivative

Recitation 2: The Derivative Mth 1c TA: Pdric Brtlett Recittion 2: The Derivtive Week 2 Cltech 2013 1 The Derivtive This recittion is centered round the ide of derivtive in R n, nd how we cn develop good notion of the derivtive in

More information

Turing Machine Extensions

Turing Machine Extensions Red K & S 4.3.1, 4.4. Do Homework 19. Turing Mchine Extensions Turing Mchine Definitions An lterntive definition of Turing mchine: (K, Σ, Γ, δ, s, H): Γ is finite set of llowble tpe symbols. One of these

More information

kx 0 x 1 k 1 0 x = 0 f(x) = 1 x > 0.

kx 0 x 1 k 1 0 x = 0 f(x) = 1 x > 0. . Sequences of Functions.. Pointwise nd Uniform Convergence. Let {f k } nd f be complex-vlued functions on common domin D. Definition.. f k f pointwise on D if, for every x D, for every ε >, there exists

More information

5. Relations and Partitions

5. Relations and Partitions 46 MATH10101 5. Reltions nd Prtitions See PJE ch.22. We defined congruence modulo m. This is n exmple of reltion on the set Z of integers. Moreover, this reltion stisfies the three properties of being

More information

Assuming all values are initially zero, what are the values of A and B after executing this Verilog code inside an always block? C=1; A <= C; B = C;

Assuming all values are initially zero, what are the values of A and B after executing this Verilog code inside an always block? C=1; A <= C; B = C; B-26 Appendix B The Bsics of Logic Design Check Yourself ALU n [Arthritic Logic Unit or (rre) Arithmetic Logic Unit] A rndom-numer genertor supplied s stndrd with ll computer systems Stn Kelly-Bootle,

More information

fraction arithmetic. For example, consider this problem the 1995 TIMSS Trends in International Mathematics and Science Study:

fraction arithmetic. For example, consider this problem the 1995 TIMSS Trends in International Mathematics and Science Study: In recent yers, mthemtics eductors hve begun to relize tht understnding frctions nd frctionl rithmetic is the gtewy to dvnced high school mthemtics. 1 Yet, US students continue to do poorly when rnked

More information

MATLAB Workshop 13 - Linear Systems of Equations

MATLAB Workshop 13 - Linear Systems of Equations MATLAB: Workshop - Liner Systems of Equtions pge MATLAB Workshop - Liner Systems of Equtions Objectives: Crete script to solve commonly occurring problem in engineering: liner systems of equtions. MATLAB

More information

Assuming all values are initially zero, what are the values of A and B after executing this Verilog code inside an always block? C=1; A <= C; B = C;

Assuming all values are initially zero, what are the values of A and B after executing this Verilog code inside an always block? C=1; A <= C; B = C; B-26 Appendix B The Bsics of Logic Design Check Yourself ALU n [Arthritic Logic Unit or (rre) Arithmetic Logic Unit] A rndom-numer genertor supplied s stndrd with ll computer systems Stn Kelly-Bootle,

More information

Review of Gaussian Quadrature method

Review of Gaussian Quadrature method Review of Gussin Qudrture method Nsser M. Abbsi June 0, 014 1 The problem To find numericl vlue for the integrl of rel vlued function of rel vrible over specific rnge over the rel line. This mens to evlute

More information

5. The distribution of gains between individuals within countries. The ability to trade (voluntarily, non-coerced) leads to mutual gains from trade.

5. The distribution of gains between individuals within countries. The ability to trade (voluntarily, non-coerced) leads to mutual gains from trade. Gins from Trde: unotes3 1 1. Mutul gins from exchnge 2. Gins from speciliztion 3. The gins-from-trde theorem 4. The distribution of gins between countries 5. The distribution of gins between individuls

More information

Gaussian Quadrature. James Keesling. 1 Quadrature Using Points with Unequal Spacing

Gaussian Quadrature. James Keesling. 1 Quadrature Using Points with Unequal Spacing Gussin Qudrture Jmes Keesling 1 Qudrture Using Points with Unequl Spcing In Newton-Cotes Integrtion we used points tht were eqully spced. However, there ws no need for the points to hve ny specil spcing.

More information

Section 4.1. Figure Region beneath the graph of y = f(x) and over the interval [a, b]

Section 4.1. Figure Region beneath the graph of y = f(x) and over the interval [a, b] Difference Equtions to Differentil Equtions Section. The Definite Integrl As we discussed in Section., nd mentioned gin t the beginning of Section 3., there re two bsic problems in clculus. In Chpter 3

More information

Building Finite Automata From Regular Expressions

Building Finite Automata From Regular Expressions Building Automt From Regulr Expressions We mke n FA from regulr expression in two steps: Trnsform the regulr expression into n NFA. Trnsform the NFA into deterministic FA. The first step is esy. Regulr

More information

LINEAR ALGEBRA GABRIEL NAGY

LINEAR ALGEBRA GABRIEL NAGY LINEAR ALGEBRA GABRIEL NAGY Contents Systems of liner equtions Row picture Column picture 5 3 Guss elimintion method 9 4 The spn of set of vectors 3 5 Mtri-vector product 4 6 Homogeneous liner systems

More information

Work Experience Log. Get ready for the future you want!

Work Experience Log. Get ready for the future you want! Work Experience Log Get redy for the future you wnt! Work Experience Log 2 Work Experience Log 3 Plcement detils The person in chrge of work experience t your school will give you informtion to help you

More information

Systems, Matrices, and Applications Systems of Linear Equations

Systems, Matrices, and Applications Systems of Linear Equations Mt Dr. Firoz -: System of equtions nd mtrices Systems, Mtrices, nd pplictions Systems of Liner Equtions System of eqution (Hs solution) Consistent Inconsistent (hs no solution) Dependent For Emple: Consider

More information

Rational Expressions

Rational Expressions C H A P T E R Rtionl Epressions nformtion is everywhere in the newsppers nd mgzines we red, the televisions we wtch, nd the computers we use. And I now people re tlking bout the Informtion Superhighwy,

More information

x 1 a To find ε 0, we square both sides of the last equation. Remember, we are after a number whose square is a.

x 1 a To find ε 0, we square both sides of the last equation. Remember, we are after a number whose square is a. iterte.mcd Introduction to successive itertion nd open the door to numericl methods with the squre root emple. This worksheet includes severl nimtion clips on successive itertion. Instructor: Nm Sun Wng

More information

4.11 Inner Product Spaces

4.11 Inner Product Spaces 314 CHAPTER 4 Vector Spces 9. A mtrix of the form 0 0 b c 0 d 0 0 e 0 f g 0 h 0 cnnot be invertible. 10. A mtrix of the form bc d e f ghi such tht e bd = 0 cnnot be invertible. 4.11 Inner Product Spces

More information

11.4 Regular Language Topics

11.4 Regular Language Topics 54 Regulr Lnguges nd Finite Automt Find simple regulr expression for the regulr lnguge recognized by this NFA. Hint: Trnsform the NFA into DFA, nd then find the minimum-stte DFA. Chllenge 12. Wht cn you

More information

Simplifying Fractions

Simplifying Fractions Worksheet.3 Frctions Section Simplifying Frctions Frctions rise often in everydy life. We use them when shopping, when cooking nd when building. Numeric frctions hve the form frction = numertor denomintor

More information

Uniform convergence and its consequences

Uniform convergence and its consequences Uniform convergence nd its consequences The following issue is centrl in mthemtics: On some domin D, we hve sequence of functions {f n }. This mens tht we relly hve n uncountble set of ordinry sequences,

More information

Quick Review of the Definition of the Definite Integral

Quick Review of the Definition of the Definite Integral Quick Review of the Definition of the Definite Integrl Philippe B. Lvl KSU Tody Philippe B. Lvl (KSU) Definite Integrl Tody 1 / 25 Introduction This is quick review of the mteril relted to the definition

More information

Application: Arc Length

Application: Arc Length Appliction: Arc Length 7 The Generl Problem The Riemnn integrl hs wide vriety of pplictions In this section, using the subdivide nd conquer strtegy we will show how it cn be used to determine the lengths

More information

Trigonometric Review Part 2

Trigonometric Review Part 2 1 Trigonometric Review Prt Identities If, y is point on the unit circle corresponding to the ngle, we know nd y, y is point on the unit circle, then Becuse y 1 This mens tht 1 This is usully denoted s

More information

Scalar Line Integrals

Scalar Line Integrals Mth 3B Discussion Session Week 5 Notes April 6 nd 8, 06 This week we re going to define new type of integrl. For the first time, we ll be integrting long something other thn Eucliden spce R n, nd we ll

More information

9 CONTINUOUS DISTRIBUTIONS

9 CONTINUOUS DISTRIBUTIONS 9 CONTINUOUS DISTIBUTIONS A rndom vrible whose vlue my fll nywhere in rnge of vlues is continuous rndom vrible nd will be ssocited with some continuous distribution. Continuous distributions re to discrete

More information

Generalized Inverses: How to Invert a Non-Invertible Matrix

Generalized Inverses: How to Invert a Non-Invertible Matrix Generlized Inverses: How to Invert Non-Invertible Mtrix S. Swyer September 7, 2006 rev August 6, 2008. Introduction nd Definition. Let A be generl m n mtrix. Then nturl question is when we cn solve Ax

More information

Binary Representation of Numbers Autar Kaw

Binary Representation of Numbers Autar Kaw Binry Representtion of Numbers Autr Kw After reding this chpter, you should be ble to: 1. convert bse- rel number to its binry representtion,. convert binry number to n equivlent bse- number. In everydy

More information

BASIC DIFFERENTIAL GEOMETRY: VARIATIONAL THEORY OF GEODESICS

BASIC DIFFERENTIAL GEOMETRY: VARIATIONAL THEORY OF GEODESICS BASIC DIFFERETIAL GEOMETRY: VARIATIOAL THEORY OF GEODESICS WERER BALLMA Introduction We ssume throughout tht M is Riemnnin mnifold. For points p, q in M, we sk for the criticl points of the length functionl

More information