MAT 4725 Numerical Analysis Section 1.4 Loops with “do” statements

Slides:



Advertisements
Similar presentations
Power Series Definition of Power Series Convergence of Power Series
Advertisements

Programming Methodology (1). Iteration Learning objectives explain the term iteration; repeat a section of code with a for loop; repeat a section of.
Looping Structures: Do Loops
Case study 1: Calculate the approximation of Pi
Taylor’s Theorem Section 9.3a. While it is beautiful that certain functions can be represented exactly by infinite Taylor series, it is the inexact Taylor.
ITC 240: Web Application Programming
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
Theorems on divergent sequences. Theorem 1 If the sequence is increasing and not bounded from above then it diverges to +∞. Illustration =
Lecture 12 Another loop for repetition The while loop construct © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Copyright © 2007 Pearson Education, Inc. Slide 8-1 Warm-Up Find the next term in the sequence: 1, 1, 2, 6, 24, 120,…
Monotone Sequences Objective: To define a Monotone Sequence and determine whether it converges or not.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
MAT 4830 Mathematical Modeling Section 1.3 Conditional Statements
For Loops 2 ENGR 1181 MATLAB 9. For Loops and Looped Programming in Real Life As first introduced last lecture, looping within programs has long been.
Chapter 1 Infinite Series. Definition of the Limit of a Sequence.
10.2 Sequences Math 6B Calculus II. Limit of Sequences from Limits of Functions.
9.1 Sequences. A sequence is a list of numbers written in an explicit order. n th term Any real-valued function with domain a subset of the positive integers.
 2003 Prentice Hall, Inc. All rights reserved. 1 Functions and Recursion Outline Function Templates Recursion Example Using Recursion: The Fibonacci Series.
C++ Beginner Tutorial: Functions IV Recursion. What is recursion? A property of function to be able to call itself… Get factorial of a given number: Factorial.
MAT 4830 Mathematical Modeling Section 1.4 Conditional Statements
The importance of sequences and infinite series in calculus stems from Newton’s idea of representing functions as sums of infinite series.  For instance,
Absolute vs. Conditional Convergence Alternating Series and the Alternating Series Test.
Factorial Notation For any positive integer n, n! means: n (n – 1) (n – 2)... (3) (2) (1) 0! will be defined as equal to one. Examples: 4! = =
Learning to love the SAS LAG function Phuse 9-12 October 2011 Herman Ament, MSD, Oss NL Phuse 9-12 October 2011.
Copyright © Cengage Learning. All rights reserved.
Algorithms and Flowcharts for Programming CFD
For Loops 1 ENGR 1181 MATLAB 8. For Loops and Looped Programming in Real Life Looping within programs has long been a useful tool for completing mundane.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
PROGRAMMING ITERATION 2. Starter  Put the following code in order (write down the line numbers).  The program should display the numbers 1-24 on screen.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Structured Programming: Debugging and Practice by the end of this class you should be able to: debug a program using echo printing debug a program using.
Lesson 11-1 Sequences. Vocabulary Sequence – a list of numbers written in a definite order { a 1, a 2, a 3, a n-1, a n } Fibonacci sequence – a recursively.
Introduction to Real Analysis Dr. Weihu Hong Clayton State University 9/18/2008.
Lecture 4 - Numerical Errors CVEN 302 June 10, 2002.
Section 8.2: Series Practice HW from Stewart Textbook (not to hand in) p. 575 # 9-15 odd, 19, 21, 23, 25, 31, 33.
9.3 Taylor’s Theorem Quick Review Tell whether the function has derivatives of all orders at the given values of a.
While Loops ENGR 1181 MATLAB 10.
MAT 4725 Numerical Analysis Section 2.1 The Bisection Method
Sequences Lesson 8.1. Definition A succession of numbers Listed according to a given prescription or rule Typically written as a 1, a 2, … a n Often shortened.
Sum of Arithmetic Sequences. Definitions Sequence Series.
Sequences (11/14/12) A sequence is an infinite list of real numbers: {a1, a2, a3, a4, a5 ….} = {an}. (Order counts!) A sequence can be described by listing.
3-1 © 2011 Pearson Prentice Hall. All rights reserved Chapter 12 Sequences, Series, and the Binomial Theorem Active Learning Questions.
INFINITE SEQUENCES AND SERIES The convergence tests that we have looked at so far apply only to series with positive terms.
Algebra II Honors Problem of the Day Homework: p odds Find the first 6 terms of the sequence defined as: Fibonacci!
Theorem Suppose {a n } is non-decreasing and bounded above by a number A. Then {a n } converges to some finite limit a, with a  A. Suppose {b n } is non-increasing.
Agenda 9/27 DO NOW (3 parts) ◦Prove the following: 1.The length of a square is 5 cm. What is the measure of its width? How can you be sure? 2.What is the.
MAT 1236 Calculus III Section 11.2 Series Part II
10.1 Sequences Tues Feb 16 Do Now Find the next three terms 1, -½, ¼, -1/8, …
Final Review – Exam 3 Sequences & Series Improper Integrals.
MAT 4725 Numerical Analysis Section 8.2 Orthogonal Polynomials and Least Squares Approximations (Part II)
11.1 Sequences. A sequence is a list of numbers written in an explicit order. n th term Any real-valued function with domain a subset of the positive.
SECTION 8.3 THE INTEGRAL AND COMPARISON TESTS. P2P28.3 INFINITE SEQUENCES AND SERIES  In general, it is difficult to find the exact sum of a series.
Sequences Lesson 8.1.
Think What will be the output?
MAT 4725 Numerical Analysis
CISC101 Reminders Quiz 1 grading underway Next Quiz, next week.
Sequences (11/13/13) A sequence is an infinite list of real numbers: {a1, a2, a3, a4, a5 ….} = {an}. (Order counts!) A sequence can be described by listing.
Clicker Question 1 The shortest interval which the Integral Test guarantees us will contain the value of is: A. 0 to 1 B. 0 to ½ C.
The Integral Test; p-Series
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
The sum of any two even integers is even.
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Section 8.1: Sequences.
EECE.2160 ECE Application Programming
A LESSON IN LOOPING What is a loop?
do/while Selection Structure
Sec 11.1: SEQUENCES DEF: A sequence is a list of numbers written in a definite order: Example first term second term n-th term Example Example.
Types of loops definite loop: A loop that executes a known number of times. Examples: Repeat these statements 10 times. Repeat these statements k times.
Warm Up Write the first 4 terms of each sequence:
Presentation transcript:

MAT 4725 Numerical Analysis Section 1.4 Loops with “do” statements

Homework Download homework from the web Read while-do loop documentations format printing Quiz on 1.6.2, we will not lecture on that section

Preview Monotonic Sequence Theorem (Stewart, section 12.1) Introduce the first type of repetition statements – the for loop Allow a specific section of code to be executed a number of times Introduces simple arrays

Definition A sequence {a n } is bounded above if  M such that a n  M  n A sequence {a n } is bounded below if  m such that a n  m  n

Monotonic Sequence Theorem The following sequences are convergent Increasing and bounded above Decreasing and bounded below

Example Show that the sequence defined by is convergent and find its limit.

Example From homework 01, we know

Zeng Section 1.4 Please listen to the explanations before you type in the program. It takes one minute to explain.

Example 1 Print the square of the first 10 positive integers What is the task being repeated?

Example 1

Example 1 > sq(); 1 4 9

Structure of the for loop

Example 2 Print the square of the first 10 positive odd integers

Example 2

> sq2();

Example 3 Print the square of the first n positive integers

Example 3 Print the square of the first n positive integers Introduces array and seq Note that these commands are not necessary here

Example 3

> sq3(2); 1, 4 > sq3(5); 1, 4, 9, 16, 25

Example 4 Fibonacci sequence is defined by

Example 4 Write a program that generate the first n+1 terms of the Fibonacci sequence F 0,F 1,…,F n

Example 4

What happen if we do not initialize F?

Example 4 Why there is no print statement?

Example 4

Example 5 Write a program, for the input of x and n, to approximate the value of sin(x) by the first sum of the first n+1 terms in the Taylor series.

Example 5