Tutorial 11 of CSCI2110 Number of Sequence & Recursion Tutor: Zhou Hong ( 周宏 )

Slides:



Advertisements
Similar presentations
Chapter Recurrence Relations
Advertisements

One Potato, Two Potato, … Mathematics of Elimination John A. Frohliger St. Norbert College.
HW # 70 - p. 306 & 307 # 6-18 even AND Warm up Simplify
Chapter 3 Mathematics of Finance
Chapter 3 Mathematics of Finance
Annuities and Sinking Funds
The Time Value of Money: Annuities and Other Topics
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
ANNUITIES Sequences and Series
Chapter 5 Mathematics of Finance
Mixed Recursion: Sec. 8.4 Exercise 3. The closed-form formula for the Towers of Hanoi problem, M n = 2 n – 1, can be proved by mathematical induction.
Recursion Lecture 18: Nov 18.
Number Sequences Lecture 5 (chapter 4.1 of the book and chapter 9 of the notes) ? overhang.
Warm Up 1. What is 35 increased by 8%? 37.8 Course More Applications of Percents.
State University of New York WARNING All rights reserved. No part of the course materials used in the instruction of this course may be reproduced in any.
Appendix – Compound Interest: Concepts and Applications
April 9, 2015Applied Discrete Mathematics Week 9: Relations 1 Solving Recurrence Relations Another Example: Give an explicit formula for the Fibonacci.
The Binomial Probability Distribution and Related Topics 5.
Present Value of an Annuity; Amortization (3.4) In this section, we will address the problem of determining the amount that should be deposited into an.
Recursion.
CSC2110 Discrete Mathematics Tutorial 4 Number Sequence Hackson Leung.
Topic # 03 TVM Effective Annual Rate and Annuities Senior Lecturer
Today’s quiz on 8.2 A Graphing Worksheet 1 will be given at the end of class. You will have 12 minutes to complete this quiz, which will consist of one.
Copyright © 2011 Pearson Prentice Hall. All rights reserved. The Time Value of Money: Annuities and Other Topics Chapter 6.
TIME VALUE OF MONEY CHAPTER 5.
MATH 102 Contemporary Math S. Rook
Excel: Project 1 Personal Budget Computer Information Technology.
Applied Discrete Mathematics Week 9: Relations
Section 1.1, Slide 1 Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 8.5, Slide 1 Consumer Mathematics The Mathematics of Everyday Life 8.
Number Sequences Lecture 7: Sep 29 ? overhang. This Lecture We will study some simple number sequences and their properties. The topics include: Representation.
MA/CSSE 473 Day 20 Josephus problem Transform and conquer examples.
1 Welcome to EC 382: International Economics By: Dr. Jacqueline Khorassani Week Eleven.
Interest Rate Futures Mark Fielding-Pritchard of mefielding.com ACCA p4, also CFA, ICAS, ICAEW mefielding.com1.
Finite Mathematics & Its Applications, 10/e by Goldstein/Schneider/SiegelCopyright © 2010 Pearson Education, Inc. 1 of 73 Chapter 11 Difference Equations.
INTEREST Simple Interest- this is where interest accumulates at a steady rate each period The formula for this is 1 +it Compound Interest is where interest.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Excel: Project 1 Personal Budget Computer Information Technology.
A few leftover Decrease-and-conquer Algorithms
Warm Up Problem Number 11 on page 326 of text book Solution: – Ordinary Interest= P x R x (days/360) – OI = 21,400 x.085 x 120/360 – OI = – Maturity.
Multiple/Continuous Compounding. Understand Effective Interest Rates Figure out how to use Inflation/Deflation in your decisions.
Excel: Project 1 Personal Budget Computer Information Technology.
Warm Up 2/5 or 2/6 Simplify:. Answers Compound Interest Compounding interest is where money earned is added to the principal and then recalculated to.
Amortized Loans An amortized loan is a loan paid off in equal payments – consequently, the loan payments are an annuity. In an amortized loan:
13.2 Recursive Definitions Objective 1) Provide the recursive definition for sequences; 2) Identify the type of a sequence from a recursive definition.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.6 Defining Sequences Recursively 1 So, Nat’ralists observe, a Flea/Hath smaller Fleas on.
MA/CSSE 473 Day 23 Transform and Conquer. MA/CSSE 473 Day 23 Scores on HW 7 were very high (class average was 93%). Good job! (Score was not included.
CSE 2813 Discrete Structures Recurrence Relations Section 6.1.
Lecture 20 Ordinary Annuities Ana Nora Evans 403 Kerchof Math 1140 Financial Mathematics.
Recurrence Relations: Selected Exercises
Quick answers If the bank is offering 12% per year compounded quarterly what would be the value of “i” in the Amount of an annuity formula? If the Nicole.
Algebra Geometric Sequences Objectives of this Section Determine if a Sequence Is Geometric Find a Formula for a Geometric Sequence Find the Sum.
Number Sequences ? overhang. This Lecture We will study some simple number sequences and their properties. The topics include: Representation of a sequence.
WARM UP/GO OVER IT: 15 MINUTES ANNOUNCEMENTS: 1 MINUTE HOMEWORK: 10 MINUTES GEOMETRIC SEQUENCES: 30 MINUTES CLASS WORK: 20 MINUTES MIDTERM RETURN/CLOSURE:
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
1. Difference Equation II 2. Interest 3. Amount with Interest 4. Consumer Loan 1.
Recurrence Relation Models
after UCI ICS/Math 6A, Summer AdvancedCounting -1 Recurrence Relations (RRs) A “Recurrence Relation”
Generating Functions and Counting Trees. Today’s Plan 1.Generating functions for basic sequences 2.Operations on generating functions 3.Counting 4.Solve.
Copyright © Cengage Learning. All rights reserved. Sequences and Series.
Agenda Lecture Content:  Recurrence Relations  Solving Recurrence Relations  Iteration  Linear homogenous recurrence relation of order k with constant.
Warm Up – 8/28/12 Bring Kleenex EC opportunity due next week. Put in box up front. Make sure your name and period is on it. We buy our workbooks on Friday,
Determine the amount saved if $375 is deposited every month for 6 years at 5.9% per year compounded monthly. N = 12 X 6 = 72 I% = 5.9 PV = 0 PMT = -375.
Objective: 1. After completing activity 1, mod With 90% accuracy 3. -Identify sequences as arithmetic, geometric, or neither -Write recursive formulas.
Find the third term of the sequence a n = 8 n + 1. Select the correct answer
The Further Mathematics Support Programme Our aim is to increase the uptake of AS and A level Mathematics and Further Mathematics to ensure that more.
Number Sequences Lecture 7: Sep 27 (chapter 4.1 of the book and chapter of the notes) ? overhang.
1. What is the order of magnitude difference between an inch and a mile? between an inch and a mile? 2. How many times bigger is a mile compared to an.
Recurrence Relations: Selected Exercises. Copyright © Peter Cappello2 Exercise 10 (a) A person deposits $1,000 in an account that yields 9% interest compounded.
MA/CSSE 473 Day 19 Sleepsort Finish Nim Josephus problem
Use mathematical induction to prove that the formula is true for all natural numbers m. {image} Choose the first step of the proof from the following:
Presentation transcript:

Tutorial 11 of CSCI2110 Number of Sequence & Recursion Tutor: Zhou Hong ( 周宏 )

HW2 & HW3 has been marked, please pick them up. HW4 will be returned in next Monday. Announcement

In your homework, you should declare your cooperators or cite references, this will not affect your grades. – Note: write your OWN solutions, do NOT just copy! Fail to do so may be considered as plagiarism. – The same notation or the same term (e.g. “imaginary women”) are clues. Announcement

Outline Number of Sequence Setup Recurrence Relations

NUMBER OF SEQUENCE

Warm Up Exercise What’s the next number? a 1 = -3, a 2 = -1, a 3 = 1, a 4 = 3, … Answer: a 5 = 5 a 1 = 3, a 2 = 6, a 3 = 12, a 4 = 24, … Answer: a 5 = 48 What about this one? a 1 =1, a 2 =11, a 3 =21, a 4 =1211, a 5 =111221, a 6 =312211, a 7 = , … Answer: a 8 = This is just for fun = )

Warm Up Exercise (Cont.) Write down the general formula of a i a 1 = -3, a 2 = -1, a 3 = 1, a 4 = 3, … Answer: a i = a 1 + (i-1)d = (i-1) = 2i - 5 a 1 = 3, a 2 = 6, a 3 = 12, a 4 = 24, … Answer: a i = a 1 q (i-1) = 3 x 2 (i-1)

Warm Up Exercise (Cont.)

Future Value Given bank rate b unchanged, if we deposit $X now, how much will we have after n years? NowAfter 1 YearAfter 2 Years…After n Years $X$X * b$X * b 2 …$X * b n Future Value: 1 dollar today will be worth b n dollars after n years.

Current Value Given bank rate b unchanged, if we want to have $X after n years, how much should we deposit now? Now…After n-2 YearsAfter n-1 YearsAfter n Years $X / b n …$X / b 2 $X / b$X Current Value: 1 dollar after n years is only worth 1 / b n dollars today.

Mortgage Loan Suppose the bank rate is b and keeps unchanged. Now, we rise a mortgage loan of $X dollars to buy a house. We have to repay the loan in n years. What is the annual repayment $p. (assume repayment is made at the end of each year)

Solution 1: Consider Future Value YearAmount to Be Repaid Now$X 1 year$X * b - $p 2 years($X * b – $p) * b – $p = $X * b 2 – $p * b – $p …… n years$X * b n – $p* b n-1 – … – $p * b – $p In order to repay the loan in n years, we must have Therefore, in each year, we have to repay

Solution 2: Consider Current Value YearCurrent Value of Each Year’s Payment 1 year$p / b 2 years$p / b 2 …… n years$p / b n The key observation is that the total current value should equal to $X. Therefore, in each year, we have to repay

RECURSION Disclaimer: Some of the slides in this section are taken from the slides by Chow Chi Wang, last year’s Tutor of CSCI2110.

Recursion Recursion is an important technique in computer science. The key idea is to reduce a problem into the similar problems in simpler cases. In this tutorial, we will focus on how to setup the recurrence relations. We will discuss solving recurrence relations in next week’s tutorial. Tip Tip: After setting up a recurrence relation, remember to test it’s correctness by trying some base cases.

Fibonacci Variant

Initiation Month 1 Month 2 Month 3 Month 4 Key: Baby rabbit pair Fertile rabbit pair

Fibonacci Variant

The Josephus Problem Flavius Josephus is a Jewish historian living in the 1st century. During the Jewish-Roman war, he and his 40 soldiers were trapped in a cave, the exit of which was blocked by Romans. The soldiers chose suicide over capture and decided that they would form a circle and proceeding around it, to kill every third remaining person until no one was left. However, Josephus wanted none of this suicide nonsense. His task is to choose a place in the initial circle so that he is the last one remaining and so survive.

The Josephus Problem in General Form There are n people numbered 1 to n around a circle. Start with people #1, eliminate every j-th remaining people until only one survives. The task is to find the survivor’s initial number. A simple case with n=10 and j=2: The elimination order: 2, 4, 6, 8, 10, 3, 7, 1, 9. So, people #5 is the survivor.

The Case of j=2 Let J(n) be the survivor’s number when start with n people. If n is a even number, we have J(2k) = 2J(k) – 1, for k >= 1. If n is a odd number, we have J(2k+1) = 2J(k) + 1, for k >= 1. Base case, J(1) = 1.

The General Value of j Note that, the position of the i-th people in the initial circle is ((i-1) mod n) + 1, starting with people #1. Consider eliminating people one by one. In the very beginning, the j-th people is eliminated, then we start the next count with the j+1-th people starting with people #1. J(n-1) is the survivor’s number in the remaining circle of n-1 people, starting with the j+1-th people in the initial circle. Then, the survivor is the (J(n-1)+j)-th people starting with people #1 in the initial circle. Therefore, we have the following recurrence relation J(1) = 1, J(n) = ((J(n-1)+j-1) mod n) + 1, for n >= 2.

Comparison of The Two Recurrence Relations J(1) = 1, J(n) = ((J(n-1)+j-1) mod n) + 1, for n >= 2. J(1) = 1, J(2k) = 2J(k) – 1, for k >= 1, J(2k+1) = 2J(k) + 1, for k >= 1. V. S.

Thank You! Q & A ?